1 | <?php |
||
20 | class HandleExceptionsMiddleware implements Middleware |
||
21 | { |
||
22 | /** |
||
23 | * @var LoggerInterface |
||
24 | */ |
||
25 | private $logger; |
||
26 | |||
27 | public function __construct(LoggerInterface $logger) |
||
31 | |||
32 | /** |
||
33 | * @var bool |
||
34 | */ |
||
35 | protected $keepSystemErrorMessage = false; |
||
36 | |||
37 | /** |
||
38 | * @param object|BaseCommand $command |
||
39 | * @param callable $next |
||
40 | * |
||
41 | * @return mixed |
||
42 | */ |
||
43 | public function execute($command, callable $next) |
||
57 | |||
58 | public function setKeepSystemErrorMessage(bool $keepSystemErrorMessage): void |
||
62 | |||
63 | private function handleDomainException(BaseCommand $command, \Exception $domainException) |
||
67 | |||
68 | private function handleArgumentException(BaseCommand $command, \InvalidArgumentException $exception) |
||
72 | |||
73 | private function handleUnclassifiedError(BaseCommand $command, \Exception $exception) |
||
77 | |||
78 | private function handleAuthenticationError(BaseCommand $command, NotAuthenticatedException $exception) |
||
82 | |||
83 | private function ensureExceptionCanBeKept(\Exception $exception): \Exception |
||
93 | } |
||
94 |