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.

66 lines 2.06 kB
/** * @module Cache */ import {} from "../../namespace/contracts/_module.js"; import {} from "../../utilities/_module.js"; /** * The error is thrown when a key is not found * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Errors */ export class KeyNotFoundCacheError extends Error { static create(key, cause) { return new KeyNotFoundCacheError(`Key "${key.get()}" is not found`, cause); } /** * Note: Do not instantiate `KeyNotFoundCacheError` 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 = KeyNotFoundCacheError.name; } } /** * The error is thrown when a key already exists found * * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Errors */ export class KeyExistsCacheError extends Error { static create(key, cause) { return new KeyExistsCacheError(`Key "${key.get()}" already exists`, cause); } /** * Note: Do not instantiate `KeyExistsCacheError` 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 = KeyExistsCacheError.name; } } /** * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Errors */ export const CACHE_ERRORS = { KeyExists: KeyExistsCacheError, KeyNotFound: KeyNotFoundCacheError, }; /** * IMPORT_PATH: `"@daiso-tech/core/cache/contracts"` * @group Errors */ export function isCacheError(value) { for (const errorClass of Object.values(CACHE_ERRORS)) { if (value instanceof errorClass) { return true; } } return false; } //# sourceMappingURL=cache.errors.js.map