Skip to content

Commit

Permalink
Merge pull request #1514 from daniellienert/bugfix/capture-any-exception
Browse files Browse the repository at this point in the history
!!!BUGFIX: Make any exception handable in renderingGroups by statusCode
  • Loading branch information
nezaniel committed Apr 10, 2024
2 parents f836b08 + 523e4bf commit e550af4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Neos.Flow/Classes/Error/AbstractExceptionHandler.php
Expand Up @@ -213,6 +213,7 @@ protected function resolveRenderingGroup(\Throwable $exception)
if (!isset($this->options['renderingGroups'])) {
return null;
}

foreach ($this->options['renderingGroups'] as $renderingGroupName => $renderingGroupSettings) {
if (isset($renderingGroupSettings['matchingExceptionClassNames'])) {
foreach ($renderingGroupSettings['matchingExceptionClassNames'] as $exceptionClassName) {
Expand All @@ -221,8 +222,9 @@ protected function resolveRenderingGroup(\Throwable $exception)
}
}
}
if (isset($renderingGroupSettings['matchingStatusCodes']) && $exception instanceof FlowException) {
if (in_array($exception->getStatusCode(), $renderingGroupSettings['matchingStatusCodes'])) {
if (isset($renderingGroupSettings['matchingStatusCodes'])) {
$statusCode = $exception instanceof FlowException ? $exception->getStatusCode(): 500;
if (in_array($statusCode, $renderingGroupSettings['matchingStatusCodes'])) {
return $renderingGroupName;
}
}
Expand Down
Expand Up @@ -153,7 +153,7 @@ An example configuration could look like in the following Settings.yaml excerpt:
key names, their actual naming has no further implications.

``matchingStatusCodes``:
an array of integer values what HTTP status codes the rendering group is for
an array of integer values what HTTP status codes the rendering group is for. Generic exceptions will be handled as if they had a 500 status code.

``matchingExceptionClassNames``:
an array of string values what Exception types the rendering group is for. Keep in mind that, as always
Expand Down

0 comments on commit e550af4

Please sign in to comment.