proofdb/vendor/illuminate/database/DetectsConcurrencyErrors.php
2026-05-01 23:40:14 +08:00

28 lines
784 B
PHP

<?php
namespace Illuminate\Database;
use Illuminate\Container\Container;
use Illuminate\Contracts\Database\ConcurrencyErrorDetector as ConcurrencyErrorDetectorContract;
use Throwable;
trait DetectsConcurrencyErrors
{
/**
* Determine if the given exception was caused by a concurrency error such as a deadlock or serialization failure.
*
* @param \Throwable $e
* @return bool
*/
protected function causedByConcurrencyError(Throwable $e)
{
$container = Container::getInstance();
$detector = $container->bound(ConcurrencyErrorDetectorContract::class)
? $container[ConcurrencyErrorDetectorContract::class]
: new ConcurrencyErrorDetector();
return $detector->causedByConcurrencyError($e);
}
}