feat: Added methods for organization
This commit is contained in:
@@ -2,7 +2,23 @@ import { HttpException, HttpStatus } from '@nestjs/common';
|
||||
|
||||
// Base exception
|
||||
export class BaseException extends HttpException {
|
||||
protected constructor(code: string, message: string, status: HttpStatus) {
|
||||
super({ code, message }, status);
|
||||
protected constructor(
|
||||
errorCode: string,
|
||||
errorMessage: string,
|
||||
status: HttpStatus
|
||||
) {
|
||||
super({ code: errorCode, message: errorMessage }, status);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Organization Exceptions
|
||||
* */
|
||||
export class OrganizationNotFoundException extends BaseException {
|
||||
|
||||
}
|
||||
// export class NotPartOfOrganizationException extends BaseException {
|
||||
// constructor(code: string, message: string, status: HttpStatus) {
|
||||
// super();
|
||||
// }
|
||||
// }
|
||||
|
||||
17
common/exceptions/error_codes.ts
Normal file
17
common/exceptions/error_codes.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { HttpStatus } from "@nestjs/common";
|
||||
|
||||
interface AppError {
|
||||
errorCode: string,
|
||||
message: string,
|
||||
status: HttpStatus
|
||||
}
|
||||
|
||||
type ErrorsType = Record<string, AppError>
|
||||
|
||||
export const ORGANIZATION_ERRORS: ErrorsType = {
|
||||
NOT_FOUND: {
|
||||
errorCode: 'ORG_001',
|
||||
message: 'Organization not found',
|
||||
status: HttpStatus.NOT_FOUND
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,5 @@
|
||||
export const PUBLIC_KEY = '__PUBLIC_KEY__';
|
||||
export const ROLE_KEY = '__ROLE_KEY__';
|
||||
export const ORG_ROLE_KEY = '__ORG_ROLE_KEY__'
|
||||
export const ORG_ROLES_ALL_KEY = '__ORG_ROLE_ALL_KEY__';
|
||||
export const CAN_PERFORM_KEY = '__CAN_PERFORM_KEY__';
|
||||
|
||||
Reference in New Issue
Block a user