UNPKG

alacritty-theme-switch

Version:
214 lines (213 loc) 6.13 kB
/** * Module for defining custom error types for file and directory operations. */ /** * Error thrown when a file is not found. */ export class FileNotFoundError extends Error { constructor(path, options) { super(`File ${path} not found.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "FileNotFoundError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when a file is not readable. */ export class FileNotReadableError extends Error { constructor(path, options) { super(`File ${path} is not readable.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "FileNotReadableError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when a file is not a TOML file. */ export class FileNotTOMLError extends Error { constructor(path, options) { super(`${path} is not a TOML file.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "FileNotTOMLError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when a path is expected to be a file but is a directory. */ export class FileIsDirectoryError extends Error { constructor(path, options) { super(`${path} is a directory.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "FileIsDirectoryError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when deleting a file fails. */ export class FileDeletionError extends Error { constructor(path, options) { super(`Failed to delete file ${path}.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "FileDeletionError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when a path is expected to be a directory but is a file. */ export class DirectoryIsFileError extends Error { constructor(path, options) { super(`Given themes directory ${path} is a file.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "DirectoryIsFileError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when a path is not a directory. */ export class DirectoryNotDirectoryError extends Error { constructor(path, options) { super(`Given themes directory ${path} is not a directory.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "DirectoryNotDirectoryError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when a directory does not exist or is not accessible. */ export class DirectoryNotAccessibleError extends Error { constructor(path, options) { super(`Given themes directory ${path} does not exist or is not readable.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "DirectoryNotAccessibleError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when creating a directory fails. */ export class DirectoryCreateError extends Error { constructor(path, options) { super(`Failed to create directory: ${path}`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "DirectoryCreateError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } } /** * Error thrown when writing to a file fails. */ export class WriteError extends Error { constructor(path, options) { super(`Failed to write to ${path}.`, options); Object.defineProperty(this, "_tag", { enumerable: true, configurable: true, writable: true, value: "WriteError" }); Object.defineProperty(this, "path", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.path = path; } }