From c79381e79c3bb10e1bcf820b3b79690a3ba7735b Mon Sep 17 00:00:00 2001 From: Sergey Krylov Date: Sun, 25 Jan 2026 10:51:02 +0300 Subject: [PATCH] feat: change exception structure --- src/modules/auth/auth.service.ts | 5 ++++- src/modules/otp/otp.service.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index ab4b632..8bd6fa5 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -61,7 +61,10 @@ export class AuthService { : await this.authRepository.findByEmail(identifier) if (!account) { - throw new RpcException('Account not found') + throw new RpcException({ + code: 5, + details: 'Account not found' + }) } if (isPhoneType && !account.isPhoneVerified) { diff --git a/src/modules/otp/otp.service.ts b/src/modules/otp/otp.service.ts index 2ced3b9..119d4d2 100644 --- a/src/modules/otp/otp.service.ts +++ b/src/modules/otp/otp.service.ts @@ -31,12 +31,18 @@ export class OtpService { ) if (!stroredHash) { - throw new RpcException('Invalid or expired code') + throw new RpcException({ + code: 5, + details: 'Invalid or expired code' + }) } const hash = createHash('sha256').update(code).digest('hex') if (stroredHash !== hash) { - throw new RpcException('Invalid or expired code') + throw new RpcException({ + code: 5, + details: 'Invalid or expired code' + }) } await this.redisService.del(`otp:${type}:${indentifier}`)