mirror of
https://github.com/morten-olsen/http.md.git
synced 2026-02-08 00:46:28 +01:00
52 lines
1.1 KiB
TypeScript
52 lines
1.1 KiB
TypeScript
class BaseError extends Error {
|
|
constructor(message: string) {
|
|
super(message);
|
|
this.name = this.constructor.name;
|
|
}
|
|
}
|
|
|
|
class FileNotFoundError extends BaseError {
|
|
constructor(filePath: string) {
|
|
super(`File not found: ${filePath}`);
|
|
}
|
|
}
|
|
|
|
class InvalidFileError extends BaseError {
|
|
#baseError?: unknown;
|
|
|
|
constructor(filePath: string, baseError?: unknown) {
|
|
super(`Invalid file: ${filePath}`);
|
|
this.#baseError = baseError;
|
|
}
|
|
|
|
get baseError() {
|
|
return this.#baseError;
|
|
}
|
|
}
|
|
|
|
class InvalidFormatError extends BaseError {
|
|
constructor(format: string) {
|
|
super(`Invalid format: ${format}`);
|
|
}
|
|
}
|
|
|
|
class ScriptError extends BaseError {
|
|
constructor(message: string) {
|
|
super(`Script error: ${message}`);
|
|
}
|
|
}
|
|
|
|
class ParsingError extends BaseError {
|
|
constructor(message: string) {
|
|
super(`Parsing error: ${message}`);
|
|
}
|
|
}
|
|
|
|
class RequiredError extends BaseError {
|
|
constructor(name: string) {
|
|
super(`Required input "${name}" is missing`);
|
|
}
|
|
}
|
|
|
|
export { BaseError, FileNotFoundError, InvalidFileError, InvalidFormatError, ScriptError, ParsingError, RequiredError };
|