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.

88 lines 2.98 kB
/** * @module Lock */ import {} from "../../namespace/_module.js"; /** * The error is thrown when trying to acquire a lock that is owned by a different owner. * * IMPORT_PATH: `"@daiso-tech/core/lock/contracts"` * @group Errors */ export class FailedAcquireLockError extends Error { static create(key, cause) { return new FailedAcquireLockError(`Key "${key.get()}" already acquired`, cause); } /** * Note: Do not instantiate `FailedAcquireLockError` 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 = FailedAcquireLockError.name; } } /** * The error is thrown when trying to release a lock that is owned by a different owner. * * IMPORT_PATH: `"@daiso-tech/core/lock/contracts"` * @group Errors */ export class FailedReleaseLockError extends Error { static create(key, lockId, cause) { return new FailedReleaseLockError(`Unonwed release on key "${key.get()}" by owner "${lockId}"`, cause); } /** * Note: Do not instantiate `FailedReleaseLockError` 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 = FailedReleaseLockError.name; } } /** * The error is thrown when trying to referesh a lock that is owned by a different owner. * * IMPORT_PATH: `"@daiso-tech/core/lock/contracts"` * @group Errors */ export class FailedRefreshLockError extends Error { static create(key, lockId, cause) { return new FailedRefreshLockError(`Unonwed refresh on key "${key.get()}" by owner "${lockId}"`, cause); } /** * Note: Do not instantiate `FailedRefreshLockError` 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 = FailedRefreshLockError.name; } } /** * * IMPORT_PATH: `"@daiso-tech/core/lock/contracts"` * @group Errors */ export const LOCK_ERRORS = { FailedAcquire: FailedAcquireLockError, FailedRelease: FailedReleaseLockError, FailedRefresh: FailedRefreshLockError, }; /** * * IMPORT_PATH: `"@daiso-tech/core/lock/contracts"` * @group Errors */ export function isLockError(value) { for (const ErrorClass of Object.values(LOCK_ERRORS)) { if (!(value instanceof ErrorClass)) { return false; } } return true; } //# sourceMappingURL=lock.errors.js.map