catch errors

main
Lee Hanken 2022-12-21 22:50:16 +00:00
parent 7c392e0dea
commit ca3a006a4a
2 changed files with 8 additions and 8 deletions

View File

@ -71,14 +71,14 @@ app.post('/', function(req, res) {
if (!html) {
res.status(400).send("Please provide a POST parameter called html");
} else {
//try {
try {
let document = new JSDOM(html);
let markdown = processor.process_dom(url, document, res, inline_title, ignore_links);
send_headers(res);
res.send(markdown);
//} catch (error) {
//res.status(400).send("Could not parse that document");
//}
} catch (error) {
res.status(400).send("Could not parse that document");
}
}
});

View File

@ -13,8 +13,8 @@ class html_reader {
JSDOM.fromURL(url).then((document)=>{
let markdown = processor.process_dom(url, document, res, inline_title, ignore_links);
res.send(markdown);
//}).catch((error)=> {
// res.status(400).send(failure_message);
}).catch((error)=> {
res.status(400).send(failure_message);
});
}
}
@ -47,8 +47,8 @@ class stack_reader {
else {
res.send(markdown_q + "\n\n## Answer\n"+ markdown_a);
}
//}).catch((error)=> {
// res.status(400).send(failure_message);
}).catch((error)=> {
res.status(400).send(failure_message);
});
}
}