From 2be5ea5ac5b2917a2c8d207ce45b60b982c58c7c Mon Sep 17 00:00:00 2001 From: razzanYoni <13521087@mahasiswa.itb.ac.id> Date: Tue, 14 Nov 2023 10:16:04 +0700 Subject: [PATCH] refactor : resolve throw error --- src/middlewares/verify-token.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/middlewares/verify-token.ts b/src/middlewares/verify-token.ts index 7273ff9..82d2257 100644 --- a/src/middlewares/verify-token.ts +++ b/src/middlewares/verify-token.ts @@ -58,12 +58,12 @@ const verifyToken = async (req: Request, res: Response, next: NextFunction) => { next(); // The token is verified, pass to the next middleware } catch (error) { if (error instanceof TokenExpiredError) { - throw new StandardError(ErrorType.ACCESS_TOKEN_EXPIRED); + next(new StandardError(ErrorType.ACCESS_TOKEN_EXPIRED)); } else if (error instanceof NotBeforeError) { - throw new StandardError(ErrorType.ACCESS_TOKEN_NOT_ACTIVE); + next(new StandardError(ErrorType.ACCESS_TOKEN_NOT_ACTIVE)); } - - throw error; + // unknown error + next(error); } }; -- GitLab