Skip to content

Commit

Permalink
feat: add TokenExpiredError handler in error-handler.middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseAlbDR committed Mar 28, 2024
1 parent 190940f commit 9406b27
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/presentation/middlewares/error-handler.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export class ErrorHandlerMiddleware {
message = 'Unknown error';
}

if (err.name && err.name === 'TokenExpiredError') {
statusCode = 401;
message = 'JWT token expired';
}

// Handle CustomAPIError
if (err instanceof CustomAPIError) {
statusCode = err.statusCode;
Expand Down

0 comments on commit 9406b27

Please sign in to comment.