UNPKG

@morodomi/ait3

Version:

AIT³ Development Platform - AI + Ticket + Test + Tool driven development methodology

70 lines (69 loc) 2.19 kB
// Custom error types for better error handling export class TicketError extends Error { code; constructor(message, code) { super(message); this.code = code; this.name = 'TicketError'; } } export class ValidationError extends TicketError { field; constructor(message, field) { super(message, 'VALIDATION_ERROR'); this.field = field; this.name = 'ValidationError'; } } export class FileSystemError extends TicketError { path; constructor(message, path) { super(message, 'FILESYSTEM_ERROR'); this.path = path; this.name = 'FileSystemError'; } } export class ConfigurationError extends TicketError { constructor(message) { super(message, 'CONFIGURATION_ERROR'); this.name = 'ConfigurationError'; } } export class LockError extends TicketError { constructor(message) { super(message, 'LOCK_ERROR'); this.name = 'LockError'; } } export class TicketNotFoundError extends TicketError { ticketId; constructor(ticketId, message) { super(message || `Ticket with ID '${ticketId}' not found`, 'TICKET_NOT_FOUND'); this.name = 'TicketNotFoundError'; this.ticketId = ticketId; } } export class TicketAlreadyInProgressError extends TicketError { ticketId; constructor(ticketId, message) { super(message || `Ticket with ID '${ticketId}' is already in progress`, 'TICKET_ALREADY_IN_PROGRESS'); this.name = 'TicketAlreadyInProgressError'; this.ticketId = ticketId; } } export class TicketAlreadyCompletedError extends TicketError { ticketId; constructor(ticketId, message) { super(message || `Ticket with ID '${ticketId}' is already completed`, 'TICKET_ALREADY_COMPLETED'); this.name = 'TicketAlreadyCompletedError'; this.ticketId = ticketId; } } export class TicketNotStartedError extends TicketError { ticketId; constructor(ticketId, message) { super(message || `Ticket with ID '${ticketId}' has not been started yet`, 'TICKET_NOT_STARTED'); this.name = 'TicketNotStartedError'; this.ticketId = ticketId; } }