Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend:auth): improve handling of sql errors

johavenf4b78fa2779d
diff --git a/backend/src/authentication/services/auth-methods/auth-method-database.service.ts b/backend/src/authentication/services/auth-methods/auth-method-database.service.ts
index 37c4104b..0c374338 100644
--- a/backend/src/authentication/services/auth-methods/auth-method-database.service.ts
+++ b/backend/src/authentication/services/auth-methods/auth-method-database.service.ts
@@ -23,7 +23,10 @@ export class AuthMethodDatabase implements AuthMethod {
user = await this.usersManager.findUser(loginOrEmail, false)
} catch (e) {
this.logger.error(`${this.validateUser.name} - ${e}`)
- throw new HttpException(CONNECT_ERROR_CODE.has(e.cause?.code) ? 'Authentication service error' : e.message, HttpStatus.INTERNAL_SERVER_ERROR)
+ throw new HttpException(
+ CONNECT_ERROR_CODE.has(e.cause?.code) ? 'Authentication service error' : e.cause?.code || e.message,
+ HttpStatus.INTERNAL_SERVER_ERROR
+ )
}
if (!user) {
this.logger.warn(`${this.validateUser.name} - login or email not found for *${loginOrEmail}*`)