37 lines
747 B
TypeScript
37 lines
747 B
TypeScript
/**
|
|
* Erreurs métier personnalisées
|
|
*/
|
|
export class BusinessError extends Error {
|
|
constructor(
|
|
message: string,
|
|
public code?: string
|
|
) {
|
|
super(message);
|
|
this.name = "BusinessError";
|
|
}
|
|
}
|
|
|
|
export class ValidationError extends BusinessError {
|
|
constructor(
|
|
message: string,
|
|
public field?: string
|
|
) {
|
|
super(message, "VALIDATION_ERROR");
|
|
this.name = "ValidationError";
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends BusinessError {
|
|
constructor(resource: string) {
|
|
super(`${resource} non trouvé`, "NOT_FOUND");
|
|
this.name = "NotFoundError";
|
|
}
|
|
}
|
|
|
|
export class ConflictError extends BusinessError {
|
|
constructor(message: string) {
|
|
super(message, "CONFLICT");
|
|
this.name = "ConflictError";
|
|
}
|
|
}
|