Skip to content

Commit

Permalink
chore: knip
Browse files Browse the repository at this point in the history
  • Loading branch information
Keyrxng committed Oct 23, 2024
1 parent dd20345 commit 1c4601b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/helpers/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { Context } from "../types";
import { addCommentToIssue } from "../handlers/add-comment";
export const logger = new Logs("debug");

export function handleUncaughtError(err: unknown) {
logger.error("An uncaught error occurred", { err });
return new Response(JSON.stringify({ err }), { status: 500, headers: { "content-type": "application/json" } });
export function handleUncaughtError(error: unknown) {
logger.error("An uncaught error occurred", { err: error });
const status = 500;
return new Response(JSON.stringify({ error }), { status: status, headers: { "content-type": "application/json" } });
}

export function sanitizeMetadata(obj: LogReturn["metadata"]): string {
return JSON.stringify(obj, null, 2).replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/--/g, "&#45;&#45;");
}
Expand Down
7 changes: 1 addition & 6 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { pluginSettingsSchema, pluginSettingsValidator } from "./types";
import { Env, envValidator } from "./types/env";
import manifest from "../manifest.json";
import { plugin } from "./plugin";
import { handleUncaughtError } from "./helpers/errors";

export default {
async fetch(request: Request, env: Env): Promise<Response> {
Expand Down Expand Up @@ -62,9 +63,3 @@ export default {
}
},
};

function handleUncaughtError(error: unknown) {
console.error(error);
const status = 500;
return new Response(JSON.stringify({ error }), { status: status, headers: { "content-type": "application/json" } });
}

0 comments on commit 1c4601b

Please sign in to comment.