Skip to content

Commit

Permalink
Public API: Add an error handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed Sep 21, 2023
1 parent d0ad40d commit ba7366c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions public-api/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ import * as env from "./env.mjs";

export default {
fetch: async function (request, _env) {
console.log("Incoming request!");
env.configure(_env);
try {
console.log("Incoming request!");
env.configure(_env);

console.log("Handling request...");
console.log("Handling request...");

const router = (await import("./routes/index.mjs")).default;
return await router.handle(request, env);
const router = (await import("./routes/index.mjs")).default;
return await router.handle(request, env);
} catch (e) {
console.error("Internal error:", e.toString(), e.stack);
return new Response("Internal Error.");
}
},
};

0 comments on commit ba7366c

Please sign in to comment.