From d6b716131146c68f683554806880c1a79f28bf85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=BCder?= Date: Sun, 14 Aug 2022 21:17:08 +0000 Subject: [PATCH] Wrap Exception handling --- index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c1cdaec..09ecec8 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,17 @@ * @param {Request} request * @returns {Promise} */ - async function handleRequest(request) { +async function handleRequest(request) { + try { + const response = await handleRequestInternal(request); + return response; + } catch(err) { + console.error(err); + throw err; + } +} + +async function handleRequestInternal(request) { const { protocol, pathname } = new URL(request.url); // Require HTTPS (TLS) connection to be secure.