Skip to content

Commit

Permalink
fix: api error
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBLT committed Mar 13, 2024
1 parent b6e74c4 commit ab8aa3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/@hec.js/api/lib/src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export class API {
const stack = [],
paramPointer = new WeakMap();

/** @type { () => Promise<Response> | null } */
const next = () => {
const r = stack.shift();

Expand Down Expand Up @@ -128,11 +129,13 @@ export class API {

findRoutes(apiRequest, this.#routes);

const r = await next().catch((error) => {
const r = await next()?.catch((error) => {
console.error(error);

context.response = '{"error": 0, "message": "See logs for information"}';
context.status = 500;

return null;
});

return r ?? new Response(context.response, { status: context.status });
Expand Down

0 comments on commit ab8aa3a

Please sign in to comment.