import { DomainError } from "./app-error"; import { AuthorizationErrorCode } from "./error-codes"; export abstract class AuthorizationError extends DomainError {} export class CannotViewError extends AuthorizationError { constructor(resourceType: string) { super( AuthorizationErrorCode.CANNOT_VIEW, `You are not authorized to view this ${resourceType}`, { resourceType }, ); } } export class CannotCreateError extends AuthorizationError { constructor(resourceType: string) { super( AuthorizationErrorCode.CANNOT_CREATE, `You are not authorized to create ${resourceType}`, { resourceType }, ); } } export class CannotUpdateError extends AuthorizationError { constructor(resourceType: string) { super( AuthorizationErrorCode.CANNOT_UPDATE, `You are not authorized to update this ${resourceType}`, { resourceType }, ); } } export class CannotDeleteError extends AuthorizationError { constructor(resourceType: string) { super( AuthorizationErrorCode.CANNOT_DELETE, `You are not authorized to delete this ${resourceType}`, { resourceType }, ); } }