Skip to content

Commit

Permalink
Merge pull request #14 from flownative/bugfix/483
Browse files Browse the repository at this point in the history
Correctly output error with CLI SAPI
  • Loading branch information
kdambekalns committed Jul 5, 2022
2 parents ff25743 + a881168 commit aece81c
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions Classes/Exception/ProductionExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,26 @@ public function handleException($exception)

$this->renderingOptions = $this->resolveCustomRenderingOptions($exception);

$exceptionWasLogged = false;
if ($this->throwableStorage instanceof ThrowableStorageInterface && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) {
$message = $this->throwableStorage->logThrowable($exception);
$this->logger->critical($message);
$exceptionWasLogged = true;
}

try {
if ($sentryClient = self::getSentryClient()) {
$sentryClient->captureThrowable($exception);
}
} catch (\Throwable $e) {
}

switch (PHP_SAPI) {
case 'cli':
try {
if ($sentryClient = self::getSentryClient()) {
$sentryClient->captureThrowable($exception);
}
} catch (\Throwable $e) {
}
echo $this->buildView($exception, $this->renderingOptions)->render();
# Doesn't return:
$this->echoExceptionCli($exception, $exceptionWasLogged);
break;
default:
try {
if ($sentryClient = self::getSentryClient()) {
$sentryClient->captureThrowable($exception);
}
} catch (\Throwable $e) {
}
$this->echoExceptionWeb($exception);
}
}
Expand Down

0 comments on commit aece81c

Please sign in to comment.