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.
2.1 kB ยท 86 lines
TypeScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687export 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, public max: number, /** Actual usage when the caller counted it โ surfaced in client error metadata. */ public current?: 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); }}