Skip to content

Commit

Permalink
fix: use errors statusCode if available
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Feb 9, 2025
1 parent 290580d commit 5995a64
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/api/src/handlers/error.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ControllerHandlerReturnType } from '../../typings/app';
import { ControllerHandlerReturnType, HTTPStatus } from '../../typings/app';

export function errorHandler(error: Error): ControllerHandlerReturnType {
export function errorHandler(
error: Error & { statusCode?: HTTPStatus }
): ControllerHandlerReturnType {
return {
status: 500,
status: error.statusCode || 500,
body: {
error: 'Internal server error',
message: error.message,
Expand Down

0 comments on commit 5995a64

Please sign in to comment.