| 1 |
<?php |
| 2 |
namespace AliNext_Lite;; |
| 3 |
|
| 4 |
use Exception; |
| 5 |
use Throwable; |
| 6 |
|
| 7 |
class FactoryException extends Exception |
| 8 |
{ |
| 9 |
protected ?array $extraData = null; |
| 10 |
|
| 11 |
public function __construct($message, ?array $extraData = null, int $code = 0, Throwable $previous = null) { |
| 12 |
parent::__construct($message, $code, $previous); |
| 13 |
} |
| 14 |
|
| 15 |
public function __toString() { |
| 16 |
if ($this->extraData) { |
| 17 |
return __CLASS__ . ": [{$this->code}]: {$this->message} \n [Extra data]: " |
| 18 |
. print_r($this->extraData, true) . "\n"; |
| 19 |
} else { |
| 20 |
return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
public function getExtraData(): ?array |
| 25 |
{ |
| 26 |
return $this->extraData; |
| 27 |
} |
| 28 |
|
| 29 |
} |
| 30 |
|