Skip to content

Commit 8c7b089

Browse files
author
Babichev Maxim
committed
Oops... return try/catch lockProvider
1 parent aaf0a74 commit 8c7b089

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/Services/LockService.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,24 @@ protected function bindTo($self, \Closure $closure): \Closure
5959
*/
6060
protected function lockProvider($self, string $name, int $seconds): Lock
6161
{
62-
/**
63-
* @var LockProvider $store
64-
*/
65-
$store = Cache::getStore();
66-
$enabled = config('wallet.lock.enabled', false);
62+
try {
63+
/**
64+
* @var LockProvider $store
65+
*/
66+
$store = Cache::getStore();
67+
$enabled = config('wallet.lock.enabled', false);
6768

68-
if ($enabled && $store instanceof LockProvider) {
69-
$class = \get_class($self);
70-
$uniqId = $class . $this->uniqId;
71-
if ($self instanceof Model) {
72-
$uniqId = $class . $self->getKey();
73-
}
69+
if ($enabled && $store instanceof LockProvider) {
70+
$class = \get_class($self);
71+
$uniqId = $class . $this->uniqId;
72+
if ($self instanceof Model) {
73+
$uniqId = $class . $self->getKey();
74+
}
7475

75-
return $store->lock("$name.$uniqId", $seconds);
76+
return $store->lock("$name.$uniqId", $seconds);
77+
}
78+
} catch (\Throwable $throwable) {
79+
// write error's
7680
}
7781

7882
return new EmptyLock();

0 commit comments

Comments
 (0)