From ca3a006a4a6b8134aff538971bdca9a0a9eb96ae Mon Sep 17 00:00:00 2001 From: Lee Hanken Date: Wed, 21 Dec 2022 22:50:16 +0000 Subject: [PATCH] catch errors --- index.js | 8 ++++---- url_to_markdown_readers.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index 290a4e5..84a7ea4 100755 --- a/index.js +++ b/index.js @@ -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"); + } } }); diff --git a/url_to_markdown_readers.js b/url_to_markdown_readers.js index 80247a2..b06f0e4 100755 --- a/url_to_markdown_readers.js +++ b/url_to_markdown_readers.js @@ -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); }); } }