Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.9 kB ยท 81 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182export type ServiceErrorCode = | "NOT_FOUND" | "FORBIDDEN" | "UNAUTHORIZED" | "CONFLICT" | "VALIDATION" | "LIMIT_EXCEEDED" | "PRECONDITION_FAILED" | "INTERNAL";
export class ServiceError extends Error { constructor( public code: ServiceErrorCode, message: string, public cause?: unknown, ) { super(message); this.name = this.constructor.name; }}
export class NotFoundError extends ServiceError { constructor( public entity: string, id?: string | number, ) { super( "NOT_FOUND", id !== undefined ? `${entity} ${id} not found` : `${entity} not found`, ); }}
export class ForbiddenError extends ServiceError { constructor(message: string) { super("FORBIDDEN", message); }}
export class UnauthorizedError extends ServiceError { constructor(message: string) { super("UNAUTHORIZED", message); }}
export class ConflictError extends ServiceError { constructor(message: string) { super("CONFLICT", message); }}
export class ValidationError extends ServiceError { constructor(message: string, cause?: unknown) { super("VALIDATION", message, cause); }}
export class LimitExceededError extends ServiceError { constructor(limit: string, max: number) { super("LIMIT_EXCEEDED", `${limit} limit reached (${max})`); }}
/** * Precondition not met โ the operation is semantically disallowed in * the current state of the system (e.g. account deletion blocked by an * active paid subscription). Distinct from `FORBIDDEN` (authorization) * and `CONFLICT` (concurrent-write race). Maps to tRPC * `PRECONDITION_FAILED`. */export class PreconditionFailedError extends ServiceError { constructor(message: string) { super("PRECONDITION_FAILED", message); }}
export class InternalServiceError extends ServiceError { constructor(message: string, cause?: unknown) { super("INTERNAL", message, cause); }}