- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Description
Hi!
I have some custom controllers using #[AdminRoute()] to integrate them into EasyAdmin. When I need to throw errors (for example, a entity don't exist) I want to show a error page to the user instead of just throwing the exception.
I can create my own error page extending EasyAdmin layouts and redirect to that route. But I wonder if EasyAdmin already provide something built-in for this.
I found the following in the source:
- A Twig template for exceptions/error pages: https://github.com/EasyCorp/EasyAdminBundle/blob/bb76b26992dd5f8d60a763dc35052e92eb5a5c6c/templates/exception.html.twig
- A base exception for EasyAdmin exceptions: https://github.com/EasyCorp/EasyAdminBundle/blob/6549e838ae68fdc2ef5a59f340d3629dc7221177/src/Exception/BaseException.php
When there is an uncontrolled exception in EasyAdmin and it's a "EasyAdmin exception", the exception twig template is rendered (see https://github.com/EasyCorp/EasyAdminBundle/blob/6549e838ae68fdc2ef5a59f340d3629dc7221177/src/EventListener/ExceptionListener.php).
I didn't find anything in the docs about how to show custom errors using EasyAdmin exception/error page. Is there a way to do it?
I tried throwing one of EasyAdmin exceptions, but it's constructor params doesn't seems quite user-friendly.
if ($entity == null) {
    throw new EntityNotFoundException(["entity_name" => "roomCategory", "entity_id_name" => "id", "entity_id_value" => $idValue]);
}If it's not currently possible to do, maybe it can be added as a new feature.
For example:
- New exception class AdminExceptionwith easier and documented parameters for it's constructor.
- Maybe a builder class (AdminExceptionBuilder/AdminErrorBuilder) to help create and configure this errors and to theAdminExceptioninstance.
 Then, the exception can be thrown and it should be handled by EasyAdminExceptionListener.
Thank you :)