- Replace class-validator with plain TypeScript interfaces in AI DTOs - Fix AIModel field names (inputCostPer1k instead of inputCostPer1m) - Fix AIUsageLog field mapping (promptTokens, completionTokens, cost) - Add 'branches', 'financial', 'sales' to MCP ToolCategory - Add branchId to McpContext interface - Create stub entities for BranchPaymentTerminal and PaymentTransaction - Create CircuitBreaker utility for payment transactions - Create database config and error classes for base.service.ts - Fix type assertions for fetch response.json() calls - Align PaymentStatus and PaymentMethod types between entities and DTOs - Add @types/pg dependency Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
/**
|
|
* Custom Error Classes
|
|
*/
|
|
|
|
export class AppError extends Error {
|
|
constructor(
|
|
message: string,
|
|
public statusCode: number = 500,
|
|
public code?: string
|
|
) {
|
|
super(message);
|
|
this.name = this.constructor.name;
|
|
Error.captureStackTrace(this, this.constructor);
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends AppError {
|
|
constructor(message: string = 'Resource not found') {
|
|
super(message, 404, 'NOT_FOUND');
|
|
}
|
|
}
|
|
|
|
export class ValidationError extends AppError {
|
|
constructor(message: string = 'Validation failed') {
|
|
super(message, 400, 'VALIDATION_ERROR');
|
|
}
|
|
}
|
|
|
|
export class UnauthorizedError extends AppError {
|
|
constructor(message: string = 'Unauthorized') {
|
|
super(message, 401, 'UNAUTHORIZED');
|
|
}
|
|
}
|
|
|
|
export class ForbiddenError extends AppError {
|
|
constructor(message: string = 'Forbidden') {
|
|
super(message, 403, 'FORBIDDEN');
|
|
}
|
|
}
|
|
|
|
export class ConflictError extends AppError {
|
|
constructor(message: string = 'Conflict') {
|
|
super(message, 409, 'CONFLICT');
|
|
}
|
|
}
|
|
|
|
export class InternalError extends AppError {
|
|
constructor(message: string = 'Internal server error') {
|
|
super(message, 500, 'INTERNAL_ERROR');
|
|
}
|
|
}
|