Files
sell/middlelayer/utils/errors.ts

29 lines
709 B
TypeScript

/**
* Custom Error-Klassen für den Middlelayer
*/
export class DataServiceError extends Error {
constructor(
message: string,
public readonly code: string,
public readonly originalError?: unknown
) {
super(message);
this.name = 'DataServiceError';
}
}
export class AdapterError extends DataServiceError {
constructor(message: string, originalError?: unknown) {
super(message, 'ADAPTER_ERROR', originalError);
this.name = 'AdapterError';
}
}
export class NotFoundError extends DataServiceError {
constructor(resource: string, identifier: string) {
super(`${resource} mit ID '${identifier}' nicht gefunden`, 'NOT_FOUND');
this.name = 'NotFoundError';
}
}