summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmilien Devos <contact@emiliendevos.be>2020-05-24 01:12:10 +0200
committerEmilien Devos <contact@emiliendevos.be>2020-05-24 01:12:10 +0200
commit91fe789e7c60cec732d4df98cb26165176cc7cbf (patch)
tree33c1da3504c5ac2e8d3274222232bb7acf19d7ad
parent159431aea3c73b75fe42991358894b5463907cbe (diff)
one liner for some functions + pass the error to the body
-rw-r--r--index.js14
1 files changed, 6 insertions, 8 deletions
diff --git a/index.js b/index.js
index ec91cb7..a307db8 100644
--- a/index.js
+++ b/index.js
@@ -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 {