Skip to content

Commit

Permalink
bug #5674 The error page can't be rendered without the context (simoh…
Browse files Browse the repository at this point in the history
…einonen)

This PR was merged into the 4.x branch.

Discussion
----------

The error page can't be rendered without the context

```
Uncaught PHP Exception EasyCorp\Bundle\EasyAdminBundle\Exception\EntityNotFoundException: "The "App\Entity\Order" entity with "orderId = " does not exist in the database. The entity may have been deleted by mistake or by a "cascade={"remove"}" operation executed by Doctrine." at /app/vendor/easycorp/easyadmin-bundle/src/Factory/EntityFactory.php line 153
Uncaught Error: Symfony\Bridge\Twig\Extension\AssetExtension::getAssetUrl(): Argument #1 ($path) must be of type string, null given, called in /app/var/cache/prod/twig/ff/ffe222c63463562719428a9eb08ba9a2.php on line 206
Uncaught PHP Exception TypeError: "Symfony\Bridge\Twig\Extension\AssetExtension::getAssetUrl(): Argument #1 ($path) must be of type string, null given, called in /app/var/cache/prod/twig/ff/ffe222c63463562719428a9eb08ba9a2.php on line 206" at /app/vendor/symfony/twig-bridge/Extension/AssetExtension.php line 46
```

In production `EntityNotFoundException` turns from 404 into 500 because the rendering failed here. Pretty annoying because 404s can just be ignored but 500 is something that should probably be looked at.

There's also #5477 which fixes this but this is should be a lot simpler

Commits
-------

eef7c68 The error page can't be rendered without the context
  • Loading branch information
javiereguiluz committed Apr 5, 2023
2 parents 2f9e851 + eef7c68 commit 1d0abe0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/EventListener/ExceptionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ public function onKernelException(ExceptionEvent $event)
return;
}

if (null === $this->adminContextProvider->getContext()) {
return;
}

// TODO: check why these custom error pages don't work
$event->setResponse($this->createExceptionResponse(FlattenException::create($exception)));
}
Expand Down

0 comments on commit 1d0abe0

Please sign in to comment.