because I got bored of customising my CV for every job
at main 44 lines 1.2 kB view raw
1import { DomainError } from "./app-error"; 2import { AuthorizationErrorCode } from "./error-codes"; 3 4export abstract class AuthorizationError extends DomainError {} 5 6export class CannotViewError extends AuthorizationError { 7 constructor(resourceType: string) { 8 super( 9 AuthorizationErrorCode.CANNOT_VIEW, 10 `You are not authorized to view this ${resourceType}`, 11 { resourceType }, 12 ); 13 } 14} 15 16export class CannotCreateError extends AuthorizationError { 17 constructor(resourceType: string) { 18 super( 19 AuthorizationErrorCode.CANNOT_CREATE, 20 `You are not authorized to create ${resourceType}`, 21 { resourceType }, 22 ); 23 } 24} 25 26export class CannotUpdateError extends AuthorizationError { 27 constructor(resourceType: string) { 28 super( 29 AuthorizationErrorCode.CANNOT_UPDATE, 30 `You are not authorized to update this ${resourceType}`, 31 { resourceType }, 32 ); 33 } 34} 35 36export class CannotDeleteError extends AuthorizationError { 37 constructor(resourceType: string) { 38 super( 39 AuthorizationErrorCode.CANNOT_DELETE, 40 `You are not authorized to delete this ${resourceType}`, 41 { resourceType }, 42 ); 43 } 44}