because I got bored of customising my CV for every job
1import { DomainError } from "@cv/system";
2
3export abstract class AuthorizationError extends DomainError {}
4
5export class CannotViewError extends AuthorizationError {
6 constructor(resourceType: string) {
7 super(
8 "AUTHORIZATION_CANNOT_VIEW",
9 `You are not authorized to view this ${resourceType}`,
10 { resourceType },
11 );
12 }
13}
14
15export class CannotCreateError extends AuthorizationError {
16 constructor(resourceType: string) {
17 super(
18 "AUTHORIZATION_CANNOT_CREATE",
19 `You are not authorized to create ${resourceType}`,
20 { resourceType },
21 );
22 }
23}
24
25export class CannotUpdateError extends AuthorizationError {
26 constructor(resourceType: string) {
27 super(
28 "AUTHORIZATION_CANNOT_UPDATE",
29 `You are not authorized to update this ${resourceType}`,
30 { resourceType },
31 );
32 }
33}
34
35export class CannotDeleteError extends AuthorizationError {
36 constructor(resourceType: string) {
37 super(
38 "AUTHORIZATION_CANNOT_DELETE",
39 `You are not authorized to delete this ${resourceType}`,
40 { resourceType },
41 );
42 }
43}