#66411New locking API exceptions too generic
Description
The new locking API currently only uses RuntimeException to hint at errors during lock acquisition.
While this already has the disadvantage of catching other RuntimeExceptions the issue becomes rather clear with the non-blocking example:
try {
$result = $locker->acquire(LockingStrategyInterface::LOCK_CAPABILITY_SHARED | LockingStrategyInterface::LOCK_CAPABILITY_NOBLOCK);
catch (\RuntimeException $e) {
if ($e->getCode() === 1428700748) {
// some process owns the lock, let's do something else meanwhile
}
}
This requires knowing about this special case and knowing the magic number here. A dedicated exception would make this clearer.