import { ConflictException } from "@nestjs/common"; /** * Exception thrown when a concurrent update conflict is detected * This occurs when optimistic locking detects that a record has been * modified by another process between read and write operations */ export class ConcurrentUpdateException extends ConflictException { constructor(resourceType: string, resourceId: string, currentVersion?: number) { const message = currentVersion ? `Concurrent update detected for ${resourceType} ${resourceId} at version ${String(currentVersion)}. The record was modified by another process.` : `Concurrent update detected for ${resourceType} ${resourceId}. The record was modified by another process.`; super({ message, error: "Concurrent Update Conflict", resourceType, resourceId, currentVersion, retryable: true, }); } }