Skip to content

Commit

Permalink
Replace StatusCode with ContentfulStatusCode
Browse files Browse the repository at this point in the history
Signed-off-by: Marvin A. Ruder <signed@mruder.dev>
  • Loading branch information
marvinruder committed Dec 28, 2024
1 parent 6c99cee commit 1c22570
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions packages/backend/src/utils/error/api/APIError.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type { StatusCode } from "hono/utils/http-status";
import type { ContentfulStatusCode } from "hono/utils/http-status";

/**
* This class is used to throw errors in the application which are associated with an HTTP status code.
*/
abstract class APIError extends Error {
status: StatusCode;
status: ContentfulStatusCode;

/**
* Creates a new instance of the {@link APIError} class.
* @param httpStatus The HTTP status code associated with the error.
* @param message A descriptive message for the error.
* @param cause The error that caused this error.
*/
constructor(httpStatus: StatusCode, message: string, cause?: Error) {
constructor(httpStatus: ContentfulStatusCode, message: string, cause?: Error) {
super(message, { cause });
Error.captureStackTrace(this, this.constructor);
this.message = message;
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/utils/error/errorHelper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Hook } from "@hono/zod-openapi";
import type { Env, ErrorHandler } from "hono";
import type { StatusCode } from "hono/utils/http-status";
import type { ContentfulStatusCode } from "hono/utils/http-status";
import { ZodError } from "zod";
import { fromError, ValidationError } from "zod-validation-error";

Expand All @@ -21,7 +21,7 @@ class ErrorHelper {
static errorHandler: ErrorHandler = (err, c) => {
Logger.error(err); // Log the error

let statusCode: StatusCode = 500;
let statusCode: ContentfulStatusCode = 500;
let message = err.message;

if (err instanceof APIError) statusCode = err.status;
Expand Down
2 changes: 1 addition & 1 deletion packages/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"./wasm.js",
"./snippets/*"
]
}
}

0 comments on commit 1c22570

Please sign in to comment.