efficiency and exception change

This commit is contained in:
Julian Krauser 2024-09-06 10:08:19 +02:00
parent 4048c21c1f
commit 88212ff79b
32 changed files with 121 additions and 124 deletions

View file

@ -22,7 +22,7 @@ export default abstract class AwardCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting award"); throw new InternalException("Failed deleting award", err);
}); });
} }
} }

View file

@ -27,7 +27,7 @@ export default abstract class CommunicationTypeCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting communicationType"); throw new InternalException("Failed deleting communicationType", err);
}); });
} }
} }

View file

@ -26,7 +26,7 @@ export default abstract class ExecutivePositionCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting executivePosition"); throw new InternalException("Failed deleting executivePosition", err);
}); });
} }
} }

View file

@ -31,7 +31,7 @@ export default abstract class InviteCommandHandler {
return token; return token;
}) })
.catch((err) => { .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() .execute()
.then((res) => {}) .then((res) => {})
.catch((err) => { .catch((err) => {
throw new InternalException("failed invite removal"); throw new InternalException("failed invite removal", err);
}); });
} }
} }

View file

@ -26,7 +26,7 @@ export default abstract class MembershipStatusCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting membershipStatus"); throw new InternalException("Failed deleting membershipStatus", err);
}); });
} }
} }

View file

@ -27,7 +27,7 @@ export default abstract class QualificationCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting qualification"); throw new InternalException("Failed deleting qualification", err);
}); });
} }
} }

View file

@ -36,7 +36,7 @@ export default abstract class RefreshCommandHandler {
return refreshToken; return refreshToken;
}) })
.catch((err) => { .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() .execute()
.then((res) => {}) .then((res) => {})
.catch((err) => { .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() .execute()
.then((res) => {}) .then((res) => {})
.catch((err) => { .catch((err) => {
throw new InternalException("failed expired refresh removal"); throw new InternalException("failed expired refresh removal", err);
}); });
} }
} }

View file

@ -22,7 +22,7 @@ export default abstract class RoleCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting role"); throw new InternalException("Failed deleting role", err);
}); });
} }
} }

View file

@ -28,47 +28,45 @@ export default abstract class RolePermissionCommandHandler {
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateRolePermissions.permissions); let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateRolePermissions.permissions);
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateRolePermissions.permissions); let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateRolePermissions.permissions);
for (let permission of newPermissions) { await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, newPermissions);
await this.updatePermissionsAdd(manager, updateRolePermissions.roleId, permission); await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, removePermissions);
}
for (let permission of removePermissions) {
await this.updatePermissionsRemove(manager, updateRolePermissions.roleId, permission);
}
}) })
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed saving role permissions"); throw new InternalException("Failed saving role permissions", err);
}); });
} }
private static async updatePermissionsAdd( private static async updatePermissionsAdd(
manager: EntityManager, manager: EntityManager,
roleId: number, roleId: number,
permission: PermissionString permissions: Array<PermissionString>
): Promise<InsertResult> { ): Promise<InsertResult> {
return await manager return await manager
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(rolePermission) .into(rolePermission)
.values({ .values(
permission: permission, permissions.map((p) => ({
permission: p,
roleId: roleId, roleId: roleId,
}) }))
)
.orIgnore()
.execute(); .execute();
} }
private static async updatePermissionsRemove( private static async updatePermissionsRemove(
manager: EntityManager, manager: EntityManager,
roleId: number, roleId: number,
permission: PermissionString permissions: Array<PermissionString>
): Promise<DeleteResult> { ): Promise<DeleteResult> {
return await manager return await manager
.createQueryBuilder() .createQueryBuilder()
.delete() .delete()
.from(rolePermission) .from(rolePermission)
.where("userId = :id", { id: roleId }) .where("roleId = :id", { id: roleId })
.andWhere("permission = :permission", { permission: permission }) .andWhere("permission IN (:...permission)", { permission: permissions })
.execute(); .execute();
} }
@ -91,7 +89,7 @@ export default abstract class RolePermissionCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then((res) => {}) .then((res) => {})
.catch((err) => { .catch((err) => {
throw new InternalException("failed role permission removal"); throw new InternalException("failed role permission removal", err);
}); });
} }
} }

View file

@ -28,7 +28,7 @@ export default abstract class UserCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .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(() => {}) .then(() => {})
.catch((err) => { .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() .execute()
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
throw new InternalException("Failed deleting user"); throw new InternalException("Failed deleting user", err);
}); });
} }
} }

View file

@ -27,48 +27,45 @@ export default abstract class UserPermissionCommandHandler {
let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateUserPermissions.permissions); let newPermissions = PermissionHelper.getWhatToAdd(currentPermissions, updateUserPermissions.permissions);
let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateUserPermissions.permissions); let removePermissions = PermissionHelper.getWhatToRemove(currentPermissions, updateUserPermissions.permissions);
for (let permission of newPermissions) { await this.updatePermissionsAdd(manager, updateUserPermissions.userId, newPermissions);
await this.updatePermissionsAdd(manager, updateUserPermissions.userId, permission); await this.updatePermissionsRemove(manager, updateUserPermissions.userId, removePermissions);
}
for (let permission of removePermissions) {
await this.updatePermissionsRemove(manager, updateUserPermissions.userId, permission);
}
}) })
.then(() => {}) .then(() => {})
.catch((err) => { .catch((err) => {
console.log(err); throw new InternalException("Failed saving user permissions", err);
throw new InternalException("Failed saving user permissions");
}); });
} }
private static async updatePermissionsAdd( private static async updatePermissionsAdd(
manager: EntityManager, manager: EntityManager,
userId: number, userId: number,
permission: PermissionString permissions: Array<PermissionString>
): Promise<InsertResult> { ): Promise<InsertResult> {
return await manager return await manager
.createQueryBuilder() .createQueryBuilder()
.insert() .insert()
.into(userPermission) .into(userPermission)
.values({ .values(
permission: permission, permissions.map((p) => ({
permission: p,
userId: userId, userId: userId,
}) }))
)
.orIgnore()
.execute(); .execute();
} }
private static async updatePermissionsRemove( private static async updatePermissionsRemove(
manager: EntityManager, manager: EntityManager,
userId: number, userId: number,
permission: PermissionString permissions: Array<PermissionString>
): Promise<DeleteResult> { ): Promise<DeleteResult> {
return await manager return await manager
.createQueryBuilder() .createQueryBuilder()
.delete() .delete()
.from(userPermission) .from(userPermission)
.where("userId = :id", { id: userId }) .where("userId = :id", { id: userId })
.andWhere("permission = :permission", { permission: permission }) .andWhere("permission IN (:...permission)", { permission: permissions })
.execute(); .execute();
} }
@ -91,7 +88,7 @@ export default abstract class UserPermissionCommandHandler {
return result.identifiers[0].id; return result.identifiers[0].id;
}) })
.catch((err) => { .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() .execute()
.then((res) => {}) .then((res) => {})
.catch((err) => { .catch((err) => {
throw new InternalException("failed user permission removal"); throw new InternalException("failed user permission removal", err);
}); });
} }
} }

View file

@ -60,7 +60,7 @@ export async function login(req: Request, res: Response): Promise<any> {
}) })
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);
throw new InternalException("Failed accessToken creation"); throw new InternalException("Failed accessToken creation", err);
}); });
let refreshCommand: CreateRefreshCommand = { let refreshCommand: CreateRefreshCommand = {
@ -128,8 +128,7 @@ export async function refresh(req: Request, res: Response): Promise<any> {
accessToken = result; accessToken = result;
}) })
.catch((err) => { .catch((err) => {
console.log(err); throw new InternalException("Failed accessToken creation", err);
throw new InternalException("Failed accessToken creation");
}); });
let refreshCommand: CreateRefreshCommand = { let refreshCommand: CreateRefreshCommand = {

View file

@ -90,7 +90,7 @@ export async function verifyInvite(req: Request, res: Response): Promise<any> {
}); });
}) })
.catch((err) => { .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; accessToken = result;
}) })
.catch((err) => { .catch((err) => {
console.log(err); throw new InternalException("Failed accessToken creation", err);
throw new InternalException("Failed accessToken creation");
}); });
let refreshCommand: CreateRefreshCommand = { let refreshCommand: CreateRefreshCommand = {

View file

@ -1,7 +1,7 @@
import CustomRequestException from "./customRequestException"; import CustomRequestException from "./customRequestException";
export default class BadRequestException extends CustomRequestException { export default class BadRequestException extends CustomRequestException {
constructor(msg: string) { constructor(msg: string, err?: any) {
super(400, msg); super(400, msg, err);
} }
} }

View file

@ -2,9 +2,11 @@ import { ExceptionBase } from "./exceptionsBaseType";
export default class CustomRequestException extends Error implements ExceptionBase { export default class CustomRequestException extends Error implements ExceptionBase {
statusCode: number; statusCode: number;
err?: any;
constructor(status: number, msg: string) { constructor(status: number, msg: string, err?: any) {
super(msg); super(msg);
this.statusCode = status; this.statusCode = status;
this.err = err;
} }
} }

View file

@ -1,7 +1,7 @@
import CustomRequestException from "./customRequestException"; import CustomRequestException from "./customRequestException";
export default class ForbiddenRequestException extends CustomRequestException { export default class ForbiddenRequestException extends CustomRequestException {
constructor(msg: string) { constructor(msg: string, err?: any) {
super(403, msg); super(403, msg, err);
} }
} }

View file

@ -1,7 +1,7 @@
import CustomRequestException from "./customRequestException"; import CustomRequestException from "./customRequestException";
export default class InternalException extends CustomRequestException { export default class InternalException extends CustomRequestException {
constructor(msg: string) { constructor(msg: string, err?: any) {
super(500, msg); super(500, msg, err);
} }
} }

View file

@ -1,7 +1,7 @@
import CustomRequestException from "./customRequestException"; import CustomRequestException from "./customRequestException";
export default class UnauthorizedRequestException extends CustomRequestException { export default class UnauthorizedRequestException extends CustomRequestException {
constructor(msg: string) { constructor(msg: string, err?: any) {
super(401, msg); super(401, msg, err);
} }
} }

View file

@ -19,9 +19,9 @@ export default async function authenticate(req: Request, res: Response, next: Fu
}) })
.catch((err) => { .catch((err) => {
if (err == "jwt expired") { if (err == "jwt expired") {
throw new UnauthorizedRequestException("Token expired"); throw new UnauthorizedRequestException("Token expired", err);
} else { } else {
throw new BadRequestException("Failed Authorization Header decoding"); throw new BadRequestException("Failed Authorization Header decoding", err);
} }
}); });

View file

@ -5,13 +5,15 @@ import CustomRequestException from "../exceptions/customRequestException";
export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) { export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) {
let status = 500; let status = 500;
let msg = "Internal Server Error"; let msg = "Internal Server Error";
let insideError = undefined;
if (err instanceof CustomRequestException) { if (err instanceof CustomRequestException) {
status = err.statusCode; status = err.statusCode;
msg = err.message; msg = err.message;
insideError = err.err;
} }
console.log("Handler", err); console.log("Handler", err, insideError);
res.status(status).send(msg); res.status(status).send(msg);
} }

View file

@ -16,8 +16,8 @@ export default abstract class AwardService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("awards not found"); throw new InternalException("awards not found", err);
}); });
} }
@ -34,8 +34,8 @@ export default abstract class AwardService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("award not found by id"); throw new InternalException("award not found by id", err);
}); });
} }
@ -53,8 +53,8 @@ export default abstract class AwardService {
// .then((res) => { // .then((res) => {
// return []; // return [];
// }) // })
// .catch(() => { // .catch((err) => {
// throw new InternalException("award assigned members not found by id"); // throw new InternalException("award assigned members not found by id", err);
// }); // });
// } // }
} }

View file

@ -17,8 +17,8 @@ export default abstract class CommunicationService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("communications not found by userid"); throw new InternalException("communications not found by userid", err);
}); });
} }

View file

@ -17,8 +17,8 @@ export default abstract class CommunicationTypeService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("communicationTypes not found"); throw new InternalException("communicationTypes not found", err);
}); });
} }
@ -35,8 +35,8 @@ export default abstract class CommunicationTypeService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("communicationType not found by id"); throw new InternalException("communicationType not found by id", err);
}); });
} }
@ -54,8 +54,8 @@ export default abstract class CommunicationTypeService {
// .then((res) => { // .then((res) => {
// return []; // return [];
// }) // })
// .catch(() => { // .catch((err) => {
// throw new InternalException("communicationType assigned members not found by id"); // throw new InternalException("communicationType assigned members not found by id", err);
// }); // });
// } // }
} }

View file

@ -16,8 +16,8 @@ export default abstract class ExecutivePositionService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("executivePositions not found"); throw new InternalException("executivePositions not found", err);
}); });
} }
@ -34,8 +34,8 @@ export default abstract class ExecutivePositionService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("executivePosition not found by id"); throw new InternalException("executivePosition not found by id", err);
}); });
} }

View file

@ -20,7 +20,7 @@ export default abstract class InviteService {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
throw new InternalException("invite not found by mail and token"); throw new InternalException("invite not found by mail and token", err);
}); });
} }
} }

View file

@ -16,8 +16,8 @@ export default abstract class MembershipStatusService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("membershipStatuss not found"); throw new InternalException("membershipStatuss not found", err);
}); });
} }
@ -34,8 +34,8 @@ export default abstract class MembershipStatusService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("membershipStatus not found by id"); throw new InternalException("membershipStatus not found by id", err);
}); });
} }
@ -53,8 +53,8 @@ export default abstract class MembershipStatusService {
// .then((res) => { // .then((res) => {
// return []; // return [];
// }) // })
// .catch(() => { // .catch((err) => {
// throw new InternalException("membershipStatus assigned members not found by id"); // throw new InternalException("membershipStatus assigned members not found by id", err);
// }); // });
// } // }
} }

View file

@ -16,8 +16,8 @@ export default abstract class QualificationService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("qualifications not found"); throw new InternalException("qualifications not found", err);
}); });
} }
@ -34,8 +34,8 @@ export default abstract class QualificationService {
.then((res) => { .then((res) => {
return res; return res;
}) })
.catch(() => { .catch((err) => {
throw new InternalException("qualification not found by id"); throw new InternalException("qualification not found by id", err);
}); });
} }
@ -53,8 +53,8 @@ export default abstract class QualificationService {
// .then((res) => { // .then((res) => {
// return []; // return [];
// }) // })
// .catch(() => { // .catch((err) => {
// throw new InternalException("qualification assigned members not found by id"); // throw new InternalException("qualification assigned members not found by id", err);
// }); // });
// } // }
} }

View file

@ -20,7 +20,7 @@ export default abstract class RefreshService {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
throw new InternalException("refresh not found"); throw new InternalException("refresh not found", err);
}); });
} }
} }

View file

@ -19,7 +19,7 @@ export default abstract class RolePermissionService {
return res; return res;
}) })
.catch((err) => { .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; return res;
}) })
.catch((err) => { .catch((err) => {
throw new InternalException("permissions not found by roles"); throw new InternalException("permissions not found by roles", err);
}); });
} }
} }

View file

@ -17,7 +17,7 @@ export default abstract class RoleService {
return res; return res;
}) })
.catch((err) => { .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; return res;
}) })
.catch((err) => { .catch((err) => {
throw new InternalException("role not found by id"); throw new InternalException("role not found by id", err);
}); });
} }
} }

View file

@ -18,7 +18,7 @@ export default abstract class UserPermissionService {
return res; return res;
}) })
.catch((err) => { .catch((err) => {
throw new InternalException("permission not found by user"); throw new InternalException("permission not found by user", err);
}); });
} }
} }

View file

@ -20,7 +20,7 @@ export default abstract class UserService {
return res; return res;
}) })
.catch((err) => { .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; return res;
}) })
.catch((err) => { .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; return res;
}) })
.catch((err) => { .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; return res;
}) })
.catch((err) => { .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; return res;
}) })
.catch((err) => { .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; return res.roles;
}) })
.catch((err) => { .catch((err) => {
throw new InternalException("could not get roles for user"); throw new InternalException("could not get roles for user", err);
}); });
} }
} }