Skip to content

Commit

Permalink
fix: only set err.status on statusCode >= 200
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed May 14, 2024
1 parent dbf5b52 commit 0403ef6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/port/middleware/ErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function ErrorHandler(ctx: EggContext, next: Next) {
}

// http status, default is DEFAULT_SERVER_ERROR_STATUS
ctx.status = err.status || DEFAULT_SERVER_ERROR_STATUS;
ctx.status = (typeof err.status === 'number' && err.status >= 200) ? err.status : DEFAULT_SERVER_ERROR_STATUS;
// don't log NotImplementedError
if (ctx.status >= DEFAULT_SERVER_ERROR_STATUS && err.name !== 'NotImplementedError') {
ctx.logger.error(err);
Expand Down

0 comments on commit 0403ef6

Please sign in to comment.