40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
export abstract class DomainException extends Error {
|
|
public readonly statusCode: number;
|
|
public readonly code: string;
|
|
|
|
constructor(message: string, statusCode: number = 400, code: string = 'DOMAIN_ERROR') {
|
|
super(message);
|
|
this.name = this.constructor.name;
|
|
this.statusCode = statusCode;
|
|
this.code = code;
|
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
}
|
|
}
|
|
|
|
export class ValidacionFiscalException extends DomainException {
|
|
constructor(message: string, code: string = 'FISCAL_VALIDATION_ERROR') {
|
|
super(message, 422, code);
|
|
}
|
|
}
|
|
|
|
export class ResolucionAgotadaException extends DomainException {
|
|
constructor(message: string) {
|
|
super(message, 409, 'RESOLUTION_EXHAUSTED_OR_EXPIRED');
|
|
}
|
|
}
|
|
|
|
export class FirmaDigitalException extends DomainException {
|
|
constructor(message: string) {
|
|
super(message, 500, 'DIGITAL_SIGNATURE_ERROR');
|
|
}
|
|
}
|
|
|
|
export class DianRechazoException extends DomainException {
|
|
public readonly dianErrors: Array<{ code: string; message: string }>;
|
|
|
|
constructor(message: string, errors: Array<{ code: string; message: string }> = []) {
|
|
super(message, 400, 'DIAN_DOCUMENT_REJECTED');
|
|
this.dianErrors = errors;
|
|
}
|
|
}
|