From 88212ff79b05c038d81d9ebfed013d879e33f17f Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Fri, 6 Sep 2024 10:08:19 +0200 Subject: [PATCH] efficiency and exception change --- src/command/awardCommandHandler.ts | 6 ++-- .../communicationTypeCommandHandler.ts | 6 ++-- .../executivePositionCommandHandler.ts | 6 ++-- src/command/inviteCommandHandler.ts | 4 +-- src/command/membershipStatusCommandHandler.ts | 6 ++-- src/command/qualificationCommandHandler.ts | 6 ++-- src/command/refreshCommandHandler.ts | 6 ++-- src/command/roleCommandHandler.ts | 6 ++-- src/command/rolePermissionCommandHandler.ts | 34 +++++++++---------- src/command/userCommandHandler.ts | 8 ++--- src/command/userPermissionCommandHandler.ts | 33 ++++++++---------- src/controller/authController.ts | 5 ++- src/controller/inviteController.ts | 5 ++- src/exceptions/badRequestException.ts | 4 +-- src/exceptions/customRequestException.ts | 4 ++- src/exceptions/forbiddenRequestException.ts | 4 +-- src/exceptions/internalException.ts | 4 +-- .../unauthorizedRequestException.ts | 4 +-- src/middleware/authenticate.ts | 4 +-- src/middleware/errorHandler.ts | 4 ++- src/service/awardService.ts | 12 +++---- src/service/communicationService.ts | 4 +-- src/service/communicationTypeService.ts | 12 +++---- src/service/executivePositionService.ts | 8 ++--- src/service/inviteService.ts | 2 +- src/service/membershipStatusService.ts | 12 +++---- src/service/qualification.ts | 12 +++---- src/service/refreshService.ts | 2 +- src/service/rolePermissionService.ts | 4 +-- src/service/roleService.ts | 4 +-- src/service/userPermissionService.ts | 2 +- src/service/userService.ts | 12 +++---- 32 files changed, 121 insertions(+), 124 deletions(-) diff --git a/src/command/awardCommandHandler.ts b/src/command/awardCommandHandler.ts index 251f70e..b862e7b 100644 --- a/src/command/awardCommandHandler.ts +++ b/src/command/awardCommandHandler.ts @@ -22,7 +22,7 @@ export default abstract class AwardCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed creating award"); + throw new InternalException("Failed creating award", err); }); } @@ -42,7 +42,7 @@ export default abstract class AwardCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating award"); + throw new InternalException("Failed updating award", err); }); } @@ -60,7 +60,7 @@ export default abstract class AwardCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting award"); + throw new InternalException("Failed deleting award", err); }); } } diff --git a/src/command/communicationTypeCommandHandler.ts b/src/command/communicationTypeCommandHandler.ts index 51b9659..2b4a1be 100644 --- a/src/command/communicationTypeCommandHandler.ts +++ b/src/command/communicationTypeCommandHandler.ts @@ -27,7 +27,7 @@ export default abstract class CommunicationTypeCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed creating communicationType"); + throw new InternalException("Failed creating communicationType", err); }); } @@ -48,7 +48,7 @@ export default abstract class CommunicationTypeCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating communicationType"); + throw new InternalException("Failed updating communicationType", err); }); } @@ -66,7 +66,7 @@ export default abstract class CommunicationTypeCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting communicationType"); + throw new InternalException("Failed deleting communicationType", err); }); } } diff --git a/src/command/executivePositionCommandHandler.ts b/src/command/executivePositionCommandHandler.ts index 3f80098..e607dd7 100644 --- a/src/command/executivePositionCommandHandler.ts +++ b/src/command/executivePositionCommandHandler.ts @@ -26,7 +26,7 @@ export default abstract class ExecutivePositionCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed creating executivePosition"); + throw new InternalException("Failed creating executivePosition", err); }); } @@ -46,7 +46,7 @@ export default abstract class ExecutivePositionCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating executivePosition"); + throw new InternalException("Failed updating executivePosition", err); }); } @@ -64,7 +64,7 @@ export default abstract class ExecutivePositionCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting executivePosition"); + throw new InternalException("Failed deleting executivePosition", err); }); } } diff --git a/src/command/inviteCommandHandler.ts b/src/command/inviteCommandHandler.ts index 5e991c9..23a5939 100644 --- a/src/command/inviteCommandHandler.ts +++ b/src/command/inviteCommandHandler.ts @@ -31,7 +31,7 @@ export default abstract class InviteCommandHandler { return token; }) .catch((err) => { - throw new InternalException("Failed saving invite"); + throw new InternalException("Failed saving invite", err); }); } @@ -50,7 +50,7 @@ export default abstract class InviteCommandHandler { .execute() .then((res) => {}) .catch((err) => { - throw new InternalException("failed invite removal"); + throw new InternalException("failed invite removal", err); }); } } diff --git a/src/command/membershipStatusCommandHandler.ts b/src/command/membershipStatusCommandHandler.ts index b6594db..b72641e 100644 --- a/src/command/membershipStatusCommandHandler.ts +++ b/src/command/membershipStatusCommandHandler.ts @@ -26,7 +26,7 @@ export default abstract class MembershipStatusCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed creating membershipStatus"); + throw new InternalException("Failed creating membershipStatus", err); }); } @@ -46,7 +46,7 @@ export default abstract class MembershipStatusCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating membershipStatus"); + throw new InternalException("Failed updating membershipStatus", err); }); } @@ -64,7 +64,7 @@ export default abstract class MembershipStatusCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting membershipStatus"); + throw new InternalException("Failed deleting membershipStatus", err); }); } } diff --git a/src/command/qualificationCommandHandler.ts b/src/command/qualificationCommandHandler.ts index a71187d..67da2f9 100644 --- a/src/command/qualificationCommandHandler.ts +++ b/src/command/qualificationCommandHandler.ts @@ -27,7 +27,7 @@ export default abstract class QualificationCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed creating qualification"); + throw new InternalException("Failed creating qualification", err); }); } @@ -48,7 +48,7 @@ export default abstract class QualificationCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating qualification"); + throw new InternalException("Failed updating qualification", err); }); } @@ -66,7 +66,7 @@ export default abstract class QualificationCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting qualification"); + throw new InternalException("Failed deleting qualification", err); }); } } diff --git a/src/command/refreshCommandHandler.ts b/src/command/refreshCommandHandler.ts index c2515f8..ae6dc0b 100644 --- a/src/command/refreshCommandHandler.ts +++ b/src/command/refreshCommandHandler.ts @@ -36,7 +36,7 @@ export default abstract class RefreshCommandHandler { return refreshToken; }) .catch((err) => { - throw new InternalException("Failed saving refresh token"); + throw new InternalException("Failed saving refresh token", err); }); } @@ -55,7 +55,7 @@ export default abstract class RefreshCommandHandler { .execute() .then((res) => {}) .catch((err) => { - throw new InternalException("failed refresh removal"); + throw new InternalException("failed refresh removal", err); }); } @@ -72,7 +72,7 @@ export default abstract class RefreshCommandHandler { .execute() .then((res) => {}) .catch((err) => { - throw new InternalException("failed expired refresh removal"); + throw new InternalException("failed expired refresh removal", err); }); } } diff --git a/src/command/roleCommandHandler.ts b/src/command/roleCommandHandler.ts index badbcb8..e967fb3 100644 --- a/src/command/roleCommandHandler.ts +++ b/src/command/roleCommandHandler.ts @@ -22,7 +22,7 @@ export default abstract class RoleCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed creating role"); + throw new InternalException("Failed creating role", err); }); } @@ -42,7 +42,7 @@ export default abstract class RoleCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating role"); + throw new InternalException("Failed updating role", err); }); } @@ -60,7 +60,7 @@ export default abstract class RoleCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting role"); + throw new InternalException("Failed deleting role", err); }); } } diff --git a/src/command/rolePermissionCommandHandler.ts b/src/command/rolePermissionCommandHandler.ts index c047a83..8502171 100644 --- a/src/command/rolePermissionCommandHandler.ts +++ b/src/command/rolePermissionCommandHandler.ts @@ -28,47 +28,45 @@ export default abstract class RolePermissionCommandHandler { let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateRolePermissions.permissions); let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateRolePermissions.permissions); - for (let permission of newPermissions) { - await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, permission); - } - - for (let permission of removePermissions) { - await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, permission); - } + await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, newPermissions); + await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, removePermissions); }) .then(() => {}) .catch((err) => { - throw new InternalException("Failed saving role permissions"); + throw new InternalException("Failed saving role permissions", err); }); } private static async updatePermissionsAdd( manager: EntityManager, roleId: number, - permission: PermissionString + permissions: Array ): Promise { return await manager .createQueryBuilder() .insert() .into(rolePermission) - .values({ - permission: permission, - roleId: roleId, - }) + .values( + permissions.map((p) => ({ + permission: p, + roleId: roleId, + })) + ) + .orIgnore() .execute(); } private static async updatePermissionsRemove( manager: EntityManager, roleId: number, - permission: PermissionString + permissions: Array ): Promise { return await manager .createQueryBuilder() .delete() .from(rolePermission) - .where("userId = :id", { id: roleId }) - .andWhere("permission = :permission", { permission: permission }) + .where("roleId = :id", { id: roleId }) + .andWhere("permission IN (:...permission)", { permission: permissions }) .execute(); } @@ -91,7 +89,7 @@ export default abstract class RolePermissionCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed saving role permission"); + throw new InternalException("Failed saving role permission", err); }); } @@ -110,7 +108,7 @@ export default abstract class RolePermissionCommandHandler { .execute() .then((res) => {}) .catch((err) => { - throw new InternalException("failed role permission removal"); + throw new InternalException("failed role permission removal", err); }); } } diff --git a/src/command/userCommandHandler.ts b/src/command/userCommandHandler.ts index 58f51d2..79834e2 100644 --- a/src/command/userCommandHandler.ts +++ b/src/command/userCommandHandler.ts @@ -28,7 +28,7 @@ export default abstract class UserCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed saving user"); + throw new InternalException("Failed saving user", err); }); } @@ -51,7 +51,7 @@ export default abstract class UserCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed updating user"); + throw new InternalException("Failed updating user", err); }); } @@ -77,7 +77,7 @@ export default abstract class UserCommandHandler { }) .then(() => {}) .catch((err) => { - throw new InternalException("Failed saving user roles"); + throw new InternalException("Failed saving user roles", err); }); } @@ -103,7 +103,7 @@ export default abstract class UserCommandHandler { .execute() .then(() => {}) .catch((err) => { - throw new InternalException("Failed deleting user"); + throw new InternalException("Failed deleting user", err); }); } } diff --git a/src/command/userPermissionCommandHandler.ts b/src/command/userPermissionCommandHandler.ts index ca676e1..f447b0b 100644 --- a/src/command/userPermissionCommandHandler.ts +++ b/src/command/userPermissionCommandHandler.ts @@ -27,48 +27,45 @@ export default abstract class UserPermissionCommandHandler { let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateUserPermissions.permissions); let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateUserPermissions.permissions); - for (let permission of newPermissions) { - await this.updatePermissionsAdd(manager, updateUserPermissions.userId, permission); - } - - for (let permission of removePermissions) { - await this.updatePermissionsRemove(manager, updateUserPermissions.userId, permission); - } + await this.updatePermissionsAdd(manager, updateUserPermissions.userId, newPermissions); + await this.updatePermissionsRemove(manager, updateUserPermissions.userId, removePermissions); }) .then(() => {}) .catch((err) => { - console.log(err); - throw new InternalException("Failed saving user permissions"); + throw new InternalException("Failed saving user permissions", err); }); } private static async updatePermissionsAdd( manager: EntityManager, userId: number, - permission: PermissionString + permissions: Array ): Promise { return await manager .createQueryBuilder() .insert() .into(userPermission) - .values({ - permission: permission, - userId: userId, - }) + .values( + permissions.map((p) => ({ + permission: p, + userId: userId, + })) + ) + .orIgnore() .execute(); } private static async updatePermissionsRemove( manager: EntityManager, userId: number, - permission: PermissionString + permissions: Array ): Promise { return await manager .createQueryBuilder() .delete() .from(userPermission) .where("userId = :id", { id: userId }) - .andWhere("permission = :permission", { permission: permission }) + .andWhere("permission IN (:...permission)", { permission: permissions }) .execute(); } @@ -91,7 +88,7 @@ export default abstract class UserPermissionCommandHandler { return result.identifiers[0].id; }) .catch((err) => { - throw new InternalException("Failed saving user permission"); + throw new InternalException("Failed saving user permission", err); }); } @@ -110,7 +107,7 @@ export default abstract class UserPermissionCommandHandler { .execute() .then((res) => {}) .catch((err) => { - throw new InternalException("failed user permission removal"); + throw new InternalException("failed user permission removal", err); }); } } diff --git a/src/controller/authController.ts b/src/controller/authController.ts index d2d7e02..cbd1a1d 100644 --- a/src/controller/authController.ts +++ b/src/controller/authController.ts @@ -60,7 +60,7 @@ export async function login(req: Request, res: Response): Promise { }) .catch((err) => { console.log(err); - throw new InternalException("Failed accessToken creation"); + throw new InternalException("Failed accessToken creation", err); }); let refreshCommand: CreateRefreshCommand = { @@ -128,8 +128,7 @@ export async function refresh(req: Request, res: Response): Promise { accessToken = result; }) .catch((err) => { - console.log(err); - throw new InternalException("Failed accessToken creation"); + throw new InternalException("Failed accessToken creation", err); }); let refreshCommand: CreateRefreshCommand = { diff --git a/src/controller/inviteController.ts b/src/controller/inviteController.ts index 095e4a3..f9be5b3 100644 --- a/src/controller/inviteController.ts +++ b/src/controller/inviteController.ts @@ -90,7 +90,7 @@ export async function verifyInvite(req: Request, res: Response): Promise { }); }) .catch((err) => { - throw new InternalException("QRCode not created"); + throw new InternalException("QRCode not created", err); }); } @@ -154,8 +154,7 @@ export async function finishInvite(req: Request, res: Response, grantAdmin: bool accessToken = result; }) .catch((err) => { - console.log(err); - throw new InternalException("Failed accessToken creation"); + throw new InternalException("Failed accessToken creation", err); }); let refreshCommand: CreateRefreshCommand = { diff --git a/src/exceptions/badRequestException.ts b/src/exceptions/badRequestException.ts index 7daf842..fdb9a38 100644 --- a/src/exceptions/badRequestException.ts +++ b/src/exceptions/badRequestException.ts @@ -1,7 +1,7 @@ import CustomRequestException from "./customRequestException"; export default class BadRequestException extends CustomRequestException { - constructor(msg: string) { - super(400, msg); + constructor(msg: string, err?: any) { + super(400, msg, err); } } diff --git a/src/exceptions/customRequestException.ts b/src/exceptions/customRequestException.ts index c412a5c..133ba68 100644 --- a/src/exceptions/customRequestException.ts +++ b/src/exceptions/customRequestException.ts @@ -2,9 +2,11 @@ import { ExceptionBase } from "./exceptionsBaseType"; export default class CustomRequestException extends Error implements ExceptionBase { statusCode: number; + err?: any; - constructor(status: number, msg: string) { + constructor(status: number, msg: string, err?: any) { super(msg); this.statusCode = status; + this.err = err; } } diff --git a/src/exceptions/forbiddenRequestException.ts b/src/exceptions/forbiddenRequestException.ts index 9fe90e1..c2cb071 100644 --- a/src/exceptions/forbiddenRequestException.ts +++ b/src/exceptions/forbiddenRequestException.ts @@ -1,7 +1,7 @@ import CustomRequestException from "./customRequestException"; export default class ForbiddenRequestException extends CustomRequestException { - constructor(msg: string) { - super(403, msg); + constructor(msg: string, err?: any) { + super(403, msg, err); } } diff --git a/src/exceptions/internalException.ts b/src/exceptions/internalException.ts index e7a0773..342db4d 100644 --- a/src/exceptions/internalException.ts +++ b/src/exceptions/internalException.ts @@ -1,7 +1,7 @@ import CustomRequestException from "./customRequestException"; export default class InternalException extends CustomRequestException { - constructor(msg: string) { - super(500, msg); + constructor(msg: string, err?: any) { + super(500, msg, err); } } diff --git a/src/exceptions/unauthorizedRequestException.ts b/src/exceptions/unauthorizedRequestException.ts index 9313e3e..b1d273e 100644 --- a/src/exceptions/unauthorizedRequestException.ts +++ b/src/exceptions/unauthorizedRequestException.ts @@ -1,7 +1,7 @@ import CustomRequestException from "./customRequestException"; export default class UnauthorizedRequestException extends CustomRequestException { - constructor(msg: string) { - super(401, msg); + constructor(msg: string, err?: any) { + super(401, msg, err); } } diff --git a/src/middleware/authenticate.ts b/src/middleware/authenticate.ts index 535a056..a62c689 100644 --- a/src/middleware/authenticate.ts +++ b/src/middleware/authenticate.ts @@ -19,9 +19,9 @@ export default async function authenticate(req: Request, res: Response, next: Fu }) .catch((err) => { if (err == "jwt expired") { - throw new UnauthorizedRequestException("Token expired"); + throw new UnauthorizedRequestException("Token expired", err); } else { - throw new BadRequestException("Failed Authorization Header decoding"); + throw new BadRequestException("Failed Authorization Header decoding", err); } }); diff --git a/src/middleware/errorHandler.ts b/src/middleware/errorHandler.ts index e3ce2ec..7b121ff 100644 --- a/src/middleware/errorHandler.ts +++ b/src/middleware/errorHandler.ts @@ -5,13 +5,15 @@ import CustomRequestException from "../exceptions/customRequestException"; export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) { let status = 500; let msg = "Internal Server Error"; + let insideError = undefined; if (err instanceof CustomRequestException) { status = err.statusCode; msg = err.message; + insideError = err.err; } - console.log("Handler", err); + console.log("Handler", err, insideError); res.status(status).send(msg); } diff --git a/src/service/awardService.ts b/src/service/awardService.ts index e9b5ff3..17c4690 100644 --- a/src/service/awardService.ts +++ b/src/service/awardService.ts @@ -16,8 +16,8 @@ export default abstract class AwardService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("awards not found"); + .catch((err) => { + throw new InternalException("awards not found", err); }); } @@ -34,8 +34,8 @@ export default abstract class AwardService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("award not found by id"); + .catch((err) => { + throw new InternalException("award not found by id", err); }); } @@ -53,8 +53,8 @@ export default abstract class AwardService { // .then((res) => { // return []; // }) - // .catch(() => { - // throw new InternalException("award assigned members not found by id"); + // .catch((err) => { + // throw new InternalException("award assigned members not found by id", err); // }); // } } diff --git a/src/service/communicationService.ts b/src/service/communicationService.ts index 441d7b9..09221dd 100644 --- a/src/service/communicationService.ts +++ b/src/service/communicationService.ts @@ -17,8 +17,8 @@ export default abstract class CommunicationService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("communications not found by userid"); + .catch((err) => { + throw new InternalException("communications not found by userid", err); }); } diff --git a/src/service/communicationTypeService.ts b/src/service/communicationTypeService.ts index 609d610..6e010f7 100644 --- a/src/service/communicationTypeService.ts +++ b/src/service/communicationTypeService.ts @@ -17,8 +17,8 @@ export default abstract class CommunicationTypeService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("communicationTypes not found"); + .catch((err) => { + throw new InternalException("communicationTypes not found", err); }); } @@ -35,8 +35,8 @@ export default abstract class CommunicationTypeService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("communicationType not found by id"); + .catch((err) => { + throw new InternalException("communicationType not found by id", err); }); } @@ -54,8 +54,8 @@ export default abstract class CommunicationTypeService { // .then((res) => { // return []; // }) - // .catch(() => { - // throw new InternalException("communicationType assigned members not found by id"); + // .catch((err) => { + // throw new InternalException("communicationType assigned members not found by id", err); // }); // } } diff --git a/src/service/executivePositionService.ts b/src/service/executivePositionService.ts index 3237dce..6fb3013 100644 --- a/src/service/executivePositionService.ts +++ b/src/service/executivePositionService.ts @@ -16,8 +16,8 @@ export default abstract class ExecutivePositionService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("executivePositions not found"); + .catch((err) => { + throw new InternalException("executivePositions not found", err); }); } @@ -34,8 +34,8 @@ export default abstract class ExecutivePositionService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("executivePosition not found by id"); + .catch((err) => { + throw new InternalException("executivePosition not found by id", err); }); } diff --git a/src/service/inviteService.ts b/src/service/inviteService.ts index 455df13..8af16ec 100644 --- a/src/service/inviteService.ts +++ b/src/service/inviteService.ts @@ -20,7 +20,7 @@ export default abstract class InviteService { return res; }) .catch((err) => { - throw new InternalException("invite not found by mail and token"); + throw new InternalException("invite not found by mail and token", err); }); } } diff --git a/src/service/membershipStatusService.ts b/src/service/membershipStatusService.ts index 2ad5ec1..5b33f46 100644 --- a/src/service/membershipStatusService.ts +++ b/src/service/membershipStatusService.ts @@ -16,8 +16,8 @@ export default abstract class MembershipStatusService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("membershipStatuss not found"); + .catch((err) => { + throw new InternalException("membershipStatuss not found", err); }); } @@ -34,8 +34,8 @@ export default abstract class MembershipStatusService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("membershipStatus not found by id"); + .catch((err) => { + throw new InternalException("membershipStatus not found by id", err); }); } @@ -53,8 +53,8 @@ export default abstract class MembershipStatusService { // .then((res) => { // return []; // }) - // .catch(() => { - // throw new InternalException("membershipStatus assigned members not found by id"); + // .catch((err) => { + // throw new InternalException("membershipStatus assigned members not found by id", err); // }); // } } diff --git a/src/service/qualification.ts b/src/service/qualification.ts index 328e093..a98fdf6 100644 --- a/src/service/qualification.ts +++ b/src/service/qualification.ts @@ -16,8 +16,8 @@ export default abstract class QualificationService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("qualifications not found"); + .catch((err) => { + throw new InternalException("qualifications not found", err); }); } @@ -34,8 +34,8 @@ export default abstract class QualificationService { .then((res) => { return res; }) - .catch(() => { - throw new InternalException("qualification not found by id"); + .catch((err) => { + throw new InternalException("qualification not found by id", err); }); } @@ -53,8 +53,8 @@ export default abstract class QualificationService { // .then((res) => { // return []; // }) - // .catch(() => { - // throw new InternalException("qualification assigned members not found by id"); + // .catch((err) => { + // throw new InternalException("qualification assigned members not found by id", err); // }); // } } diff --git a/src/service/refreshService.ts b/src/service/refreshService.ts index d18541c..a2b8a2c 100644 --- a/src/service/refreshService.ts +++ b/src/service/refreshService.ts @@ -20,7 +20,7 @@ export default abstract class RefreshService { return res; }) .catch((err) => { - throw new InternalException("refresh not found"); + throw new InternalException("refresh not found", err); }); } } diff --git a/src/service/rolePermissionService.ts b/src/service/rolePermissionService.ts index e345765..7021a2a 100644 --- a/src/service/rolePermissionService.ts +++ b/src/service/rolePermissionService.ts @@ -19,7 +19,7 @@ export default abstract class RolePermissionService { return res; }) .catch((err) => { - throw new InternalException("permissions not found by role"); + throw new InternalException("permissions not found by role", err); }); } @@ -38,7 +38,7 @@ export default abstract class RolePermissionService { return res; }) .catch((err) => { - throw new InternalException("permissions not found by roles"); + throw new InternalException("permissions not found by roles", err); }); } } diff --git a/src/service/roleService.ts b/src/service/roleService.ts index 65215ea..a344a0a 100644 --- a/src/service/roleService.ts +++ b/src/service/roleService.ts @@ -17,7 +17,7 @@ export default abstract class RoleService { return res; }) .catch((err) => { - throw new InternalException("roles not found"); + throw new InternalException("roles not found", err); }); } @@ -37,7 +37,7 @@ export default abstract class RoleService { return res; }) .catch((err) => { - throw new InternalException("role not found by id"); + throw new InternalException("role not found by id", err); }); } } diff --git a/src/service/userPermissionService.ts b/src/service/userPermissionService.ts index 1c0f778..c060264 100644 --- a/src/service/userPermissionService.ts +++ b/src/service/userPermissionService.ts @@ -18,7 +18,7 @@ export default abstract class UserPermissionService { return res; }) .catch((err) => { - throw new InternalException("permission not found by user"); + throw new InternalException("permission not found by user", err); }); } } diff --git a/src/service/userService.ts b/src/service/userService.ts index 8cd1968..bc880b1 100644 --- a/src/service/userService.ts +++ b/src/service/userService.ts @@ -20,7 +20,7 @@ export default abstract class UserService { return res; }) .catch((err) => { - throw new InternalException("users not found"); + throw new InternalException("users not found", err); }); } @@ -42,7 +42,7 @@ export default abstract class UserService { return res; }) .catch((err) => { - throw new InternalException("user not found by id"); + throw new InternalException("user not found by id", err); }); } @@ -62,7 +62,7 @@ export default abstract class UserService { return res; }) .catch((err) => { - throw new InternalException("user not found by username"); + throw new InternalException("user not found by username", err); }); } @@ -84,7 +84,7 @@ export default abstract class UserService { return res; }) .catch((err) => { - throw new InternalException("user not found by mail or username"); + throw new InternalException("user not found by mail or username", err); }); } @@ -102,7 +102,7 @@ export default abstract class UserService { return res; }) .catch((err) => { - throw new InternalException("could not count users"); + throw new InternalException("could not count users", err); }); } @@ -123,7 +123,7 @@ export default abstract class UserService { return res.roles; }) .catch((err) => { - throw new InternalException("could not get roles for user"); + throw new InternalException("could not get roles for user", err); }); } }