syncguard
Version:
Functional TypeScript library for distributed locking across microservices. Prevents race conditions with Redis, PostgreSQL, Firestore, and custom backends. Features automatic lock management, timeout handling, and extensible architecture.
20 lines (19 loc) • 597 B
JavaScript
// SPDX-FileCopyrightText: 2025-present Kriasoft
// SPDX-License-Identifier: MIT
/**
* Thrown by all lock operations for system errors, timeouts, and failures.
* Use `code` to distinguish error types and `context` for debugging details.
*/
export class LockError extends Error {
code;
context;
constructor(code, // Unexpected backend errors or quota limits
message,
/** Debugging context: lock key, ID, and underlying error */
context) {
super(message ?? code);
this.code = code;
this.context = context;
this.name = "LockError";
}
}