Skip to content

Commit

Permalink
Simplify exception logical condition
Browse files Browse the repository at this point in the history
When rendering the custom exception page, we test if the
MissingRequiredAttributeException. But it also had to be a HTTP
exception. That was never the case (also before #313).

By removing the first part of the statement, the error message is
displayed correctly once again.
  • Loading branch information
MKodde committed Mar 11, 2024
1 parent 9da4adc commit 688447b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
30 changes: 0 additions & 30 deletions ci/qa/phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,41 +301,11 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/EntryPointController.php',
];
$ignoreErrors[] = [
'message' => '#^Instanceof between Symfony\\\\Component\\\\HttpKernel\\\\Exception\\\\HttpException and Surfnet\\\\StepupSelfService\\\\SelfServiceBundle\\\\Exception\\\\MissingRequiredAttributeException will always evaluate to false\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Method Surfnet\\\\StepupSelfService\\\\SelfServiceBundle\\\\Controller\\\\ExceptionController\\:\\:getPageTitleAndDescription\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Result of && is always false\\.$#',
'count' => 2,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Undefined variable\\: \\$description$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Undefined variable\\: \\$title$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$description in isset\\(\\) is never defined\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Variable \\$title in isset\\(\\) is never defined\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Surfnet/StepupSelfService/SelfServiceBundle/Controller/ExceptionController.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot call method getIdentity\\(\\) on Symfony\\\\Component\\\\Security\\\\Core\\\\User\\\\UserInterface\\|null\\.$#',
'count' => 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
use Throwable;
use Surfnet\StepupBundle\Controller\ExceptionController as BaseExceptionController;
use Surfnet\StepupSelfService\SelfServiceBundle\Exception\MissingRequiredAttributeException;
use Symfony\Component\HttpKernel\Exception\HttpException;

final class ExceptionController extends BaseExceptionController
{
Expand All @@ -39,7 +38,7 @@ protected function getPageTitleAndDescription(Throwable $exception): array
{
$translator = $this->getTranslator();

if ($exception instanceof HttpException && $exception instanceof MissingRequiredAttributeException) {
if ($exception instanceof MissingRequiredAttributeException) {
$title = $translator->trans('stepup.error.missing_required_attribute.title');
$description = $exception->getMessage();
}
Expand Down

0 comments on commit 688447b

Please sign in to comment.