diff options
author | Emilien Devos <contact@emiliendevos.be> | 2020-05-24 01:12:10 +0200 |
---|---|---|
committer | Emilien Devos <contact@emiliendevos.be> | 2020-05-24 01:12:10 +0200 |
commit | 91fe789e7c60cec732d4df98cb26165176cc7cbf (patch) | |
tree | 33c1da3504c5ac2e8d3274222232bb7acf19d7ad /index.js | |
parent | 159431aea3c73b75fe42991358894b5463907cbe (diff) |
one liner for some functions + pass the error to the body
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -86,15 +86,13 @@ const responseHeadersToRemove = ["Accept-Ranges", "Content-Length", "Keep-Alive" }); await page.close(); } catch (error) { - if (!error.toString().includes("ERR_BLOCKED_BY_CLIENT")) - throw (error); + if (!error.toString().includes("ERR_BLOCKED_BY_CLIENT")) { + ctx.status = 500; + ctx.body = error; + } } - responseHeadersToRemove.forEach(header => { - delete responseHeaders[header]; - }); - Object.keys(responseHeaders).forEach(header => { - ctx.set(header, jsesc(responseHeaders[header])); - }); + responseHeadersToRemove.forEach(header => delete responseHeaders[header]); + Object.keys(responseHeaders).forEach(header => ctx.set(header, jsesc(responseHeaders[header]))); ctx.body = responseBody; } else { |