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 1.97 kB
/** * @module Cache */ import {} from "../../namespace/_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 is not 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 = { 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 false; } } return true; } //# sourceMappingURL=cache.errors.js.map