UNPKG

@daiso-tech/core

Version:

The library offers flexible, framework-agnostic solutions for modern web applications, built on adaptable components that integrate seamlessly with popular frameworks like Next Js.

87 lines 2.83 kB
/** * @module FileStorage */ import {} from "../../namespace/contracts/_module.js"; import {} from "../../utilities/_module.js"; /** * The error is thrown when a file key is not found * * IMPORT_PATH: `"@daiso-tech/core/file-storage/contracts"` * @group Errors */ export class KeyNotFoundFileError extends Error { static create(key, cause) { return new KeyNotFoundFileError(`Key "${key.get()}" is not found`, cause); } /** * Note: Do not instantiate `KeyNotFoundFileError` directly via the constructor. Use the static `create()` factory method instead. * The constructor remains public only to maintain compatibility with errorPolicy types and prevent type errors. * @internal */ constructor(message, cause) { super(message, { cause }); this.name = KeyNotFoundFileError.name; } } /** * The error is thrown when a file key already exists found * * IMPORT_PATH: `"@daiso-tech/core/file-storage/contracts"` * @group Errors */ export class KeyExistsFileError extends Error { static create(key, cause) { return new KeyExistsFileError(`Key "${key.get()}" already exists`, cause); } /** * Note: Do not instantiate `KeyExistsFileError` directly via the constructor. Use the static `create()` factory method instead. * The constructor remains public only to maintain compatibility with errorPolicy types and prevent type errors. * @internal */ constructor(message, cause) { super(message, { cause }); this.name = KeyExistsFileError.name; } } /** * The error is thrown when file key is invalid. * * IMPORT_PATH: `"@daiso-tech/core/file-storage/contracts"` * @group Errors */ export class InvalidKeyFileError extends Error { static create(message, cause) { return new InvalidKeyFileError(message, cause); } /** * Note: Do not instantiate `InvalidKeyFileError` directly via the constructor. Use the static `create()` factory method instead. * The constructor remains public only to maintain compatibility with errorPolicy types and prevent type errors. * @internal */ constructor(message, cause) { super(message, { cause }); this.name = InvalidKeyFileError.name; } } /** * IMPORT_PATH: `"@daiso-tech/core/file-storage/contracts"` * @group Errors */ export const FILE_STORAGE_ERRORS = { KeyNotFound: KeyNotFoundFileError, KeyExists: KeyExistsFileError, InvalidKey: InvalidKeyFileError, }; /** * IMPORT_PATH: `"@daiso-tech/core/file-storage/contracts"` * @group Errors */ export function isFileError(value) { for (const errorClass of Object.values(FILE_STORAGE_ERRORS)) { if (value instanceof errorClass) { return true; } } return false; } //# sourceMappingURL=file.errors.js.map