txtdot/src/errors/main.ts

35 lines
771 B
TypeScript
Raw Normal View History

export abstract class TxtDotError extends Error {
2023-08-21 17:35:25 +03:00
code: number;
name: string;
2023-08-21 17:35:25 +03:00
description: string;
constructor(code: number, name: string, description: string) {
2023-08-21 17:35:25 +03:00
super(description);
this.code = code;
this.name = name;
2023-08-21 17:35:25 +03:00
this.description = description;
}
}
export class EngineParseError extends TxtDotError {
constructor(message: string) {
super(422, "EngineParseError", `Parse error: ${message}`);
2023-08-21 17:35:25 +03:00
}
}
export class LocalResourceError extends TxtDotError {
constructor() {
super(403, "LocalResourceError", "Proxying local resources is forbidden.");
2023-08-21 17:35:25 +03:00
}
}
2023-08-21 16:03:28 +03:00
2023-08-16 13:20:24 +03:00
export class NotHtmlMimetypeError extends Error {
name: string = "NotHtmlMimetypeError";
2023-08-16 13:20:24 +03:00
url: string;
2023-08-21 17:35:25 +03:00
2023-08-21 16:03:28 +03:00
constructor(url: string) {
2023-08-16 13:20:24 +03:00
super();
2023-08-21 16:03:28 +03:00
this.url = url;
2023-08-16 13:20:24 +03:00
}
}