Files
Checkmate/server/src/utils/AppError.ts
T

24 lines
641 B
TypeScript
Raw Normal View History

2026-01-09 14:49:44 -08:00
export interface AppErrorConfig {
2026-03-12 11:12:46 -07:00
message?: string;
2026-01-09 14:49:44 -08:00
status?: number;
2026-03-12 11:12:46 -07:00
service?: string;
method?: string;
details?: Record<string, unknown> | undefined;
2026-01-09 14:49:44 -08:00
}
export class AppError extends Error {
2026-03-12 11:12:46 -07:00
readonly status: number;
readonly service: string;
readonly method: string;
readonly details: Record<string, unknown> | undefined;
2026-01-09 14:49:44 -08:00
2026-03-12 11:12:46 -07:00
constructor({ message, status = 500, service = "unknownService", method = "unknownMethod", details = undefined }: AppErrorConfig) {
2026-01-09 14:49:44 -08:00
super(message);
this.status = status;
this.service = service;
this.method = method;
this.details = details;
Error.captureStackTrace(this, this.constructor);
}
}