25 lines
531 B
TypeScript
25 lines
531 B
TypeScript
export interface IServerError {
|
|
readonly code: number;
|
|
readonly desc: string;
|
|
}
|
|
|
|
export class ApiValidationError implements IServerError {
|
|
readonly code: number;
|
|
readonly desc: string;
|
|
|
|
constructor(code: number, desc: string) {
|
|
this.code = code;
|
|
this.desc = desc;
|
|
}
|
|
}
|
|
|
|
export class ApiError extends ApiValidationError {
|
|
constructor(code: number, desc: string) {
|
|
super(code, desc);
|
|
}
|
|
|
|
format = (): string => {
|
|
return `Ha ocurrido un error: ${this.desc}`;
|
|
};
|
|
}
|