From fc2e6d5d606c40cecfbc3bc04a9c3352350c79fe Mon Sep 17 00:00:00 2001 From: simvalery Date: Wed, 30 Aug 2023 15:12:22 +0400 Subject: [PATCH] fix error stack trace Signed-off-by: simvalery Signed-off-by: simvalery --- api-gateway/src/api/service/account.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api-gateway/src/api/service/account.ts b/api-gateway/src/api/service/account.ts index 12e3f7f69d..7746291ed4 100644 --- a/api-gateway/src/api/service/account.ts +++ b/api-gateway/src/api/service/account.ts @@ -105,8 +105,8 @@ export class AccountApi { try { await checkPermission(UserRole.STANDARD_REGISTRY)(user); } catch (error) { - new Logger().error(error, ['API_GATEWAY']); - throw error; + new Logger().error(error.message, ['API_GATEWAY']); + throw new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR); } } try { @@ -132,7 +132,7 @@ export class AccountApi { if (error.message.includes('already exists')) { throw new HttpException('An account with the same name already exists.', HttpStatus.INTERNAL_SERVER_ERROR); } - throw error; + throw new HttpException(error.message, HttpStatus.INTERNAL_SERVER_ERROR); } } @@ -163,8 +163,8 @@ export class AccountApi { const {username, password} = body; return await users.generateNewToken(username, password) as any; } catch (error) { - new Logger().error(error, ['API_GATEWAY']); - throw error; + new Logger().warn(error.message, ['API_GATEWAY']); + throw new HttpException(error.message, HttpStatus.UNAUTHORIZED); } }