diff options
Diffstat (limited to 'src/config/errorHandler.ts')
| -rw-r--r-- | src/config/errorHandler.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/config/errorHandler.ts b/src/config/errorHandler.ts index 4333687..d6f3193 100644 --- a/src/config/errorHandler.ts +++ b/src/config/errorHandler.ts @@ -1,7 +1,8 @@ import { HiAnimeError } from "aniwatch"; import type { ErrorHandler, NotFoundHandler } from "hono"; +import type { ContentfulStatusCode } from "hono/utils/http-status"; -const errResp: { status: number; message: string } = { +const errResp: { status: ContentfulStatusCode; message: string } = { status: 500, message: "Internal Server Error", }; @@ -10,11 +11,11 @@ export const errorHandler: ErrorHandler = (err, c) => { console.error(err); if (err instanceof HiAnimeError) { - errResp.status = err.status; + errResp.status = err.status as ContentfulStatusCode; errResp.message = err.message; } - return c.json(errResp, { status: errResp.status }); + return c.json(errResp, errResp.status); }; export const notFoundHandler: NotFoundHandler = (c) => { @@ -22,5 +23,5 @@ export const notFoundHandler: NotFoundHandler = (c) => { errResp.message = "Not Found"; console.error(errResp); - return c.json(errResp, { status: errResp.status }); + return c.json(errResp, errResp.status); }; |
