Skip to content

Commit

Permalink
Added error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jameshschuler committed May 26, 2023
1 parent 1703881 commit 5c10faf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/src/middleware/handleError.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { logError } from "@/handlers/commands/createLog.handler.ts";
import { RouterContext } from "oak";

export async function handleError(ctx: RouterContext<string>, next: () => Promise<void>) {
try {
await next();
} catch (_err) {
} catch (err) {
await logError("Application Error", err);

ctx.response.status = 500;
ctx.response.body = { message: "Something went wrong processing your request. Please try again later." };
}
Expand Down

0 comments on commit 5c10faf

Please sign in to comment.