Refactor event handling and user management: Replace direct database calls with service layer methods for events, user profiles, and preferences, enhancing code organization and maintainability. Update API routes to utilize new services for event registration, feedback, and user statistics, ensuring a consistent approach across the application.
This commit is contained in:
31
services/errors.ts
Normal file
31
services/errors.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user