| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace malkusch\lock\exception; |
| 6 |
|
| 7 |
use Throwable; |
| 8 |
|
| 9 |
/** |
| 10 |
* Lock release exception. |
| 11 |
* |
| 12 |
* Failed to release the lock. Take this exception very serious. Failing to |
| 13 |
* release a lock might have the potential to introduce deadlocks. Also the |
| 14 |
* critical code was executed i.e. side effects may have happened. |
| 15 |
* |
| 16 |
* @author Markus Malkusch <markus@malkusch.de> |
| 17 |
* @link bitcoin:1P5FAZ4QhXCuwYPnLZdk3PJsqePbu1UDDA Donations |
| 18 |
* @license WTFPL |
| 19 |
*/ |
| 20 |
class LockReleaseException extends MutexException |
| 21 |
{ |
| 22 |
/** |
| 23 |
* Result that has been returned during the critical code execution. |
| 24 |
* |
| 25 |
* @var mixed |
| 26 |
*/ |
| 27 |
private $codeResult; |
| 28 |
|
| 29 |
/** |
| 30 |
* Exception that has happened during the critical code execution. |
| 31 |
* |
| 32 |
* @var \Throwable|null |
| 33 |
*/ |
| 34 |
private $codeException; |
| 35 |
|
| 36 |
/** |
| 37 |
* Gets the result that has been returned during the critical code |
| 38 |
* execution. |
| 39 |
* |
| 40 |
* @return mixed The return value of the executed code block. |
| 41 |
*/ |
| 42 |
public function getCodeResult() |
| 43 |
{ |
| 44 |
return $this->codeResult; |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Sets the result that has been returned during the critical code |
| 49 |
* execution. |
| 50 |
* |
| 51 |
* @param mixed $codeResult The return value of the executed code block. |
| 52 |
* @return self Current lock release exception instance. |
| 53 |
*/ |
| 54 |
public function setCodeResult($codeResult): self |
| 55 |
{ |
| 56 |
$this->codeResult = $codeResult; |
| 57 |
|
| 58 |
return $this; |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Gets the exception that has happened during the synchronized code |
| 63 |
* execution. |
| 64 |
* |
| 65 |
* @return \Throwable|null The exception thrown by the code block or null |
| 66 |
* when there has been no exception. |
| 67 |
*/ |
| 68 |
public function getCodeException(): ?Throwable |
| 69 |
{ |
| 70 |
return $this->codeException; |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* Sets the exception that has happened during the critical code |
| 75 |
* execution. |
| 76 |
* |
| 77 |
* @param \Throwable $codeException The exception thrown by the code block. |
| 78 |
* @return self Current lock release exception instance. |
| 79 |
*/ |
| 80 |
public function setCodeException(Throwable $codeException): self |
| 81 |
{ |
| 82 |
$this->codeException = $codeException; |
| 83 |
|
| 84 |
return $this; |
| 85 |
} |
| 86 |
} |
| 87 |
|