Closed wadjei closed 9 months ago
Hey @VincentLanglet I was having trouble getting handleModelManagerThrowable to customise the flashbag message on error and came up with the proposed PR https://github.com/sonata-project/SonataAdminBundle/pull/8141
WDYT?
Feature Request
Following from #7759, it is not possible to use the feature when the exception is of type ModelManagerException, even though these implement ModelManagerThrowable, as is the case for Doctrine UniqueConstraintViolationExceptions.
This is because, in CRUDController.php ModelManagerExceptions are caught first, before the catch for ModelManagerThrowable.
The relevant catches have been marked for removal for the last couple of years
// NEXT_MAJOR: Remove this catch.
but persist in the current 4.x and 5.x branches.Currently, I'm having to hack around this issue by overriding addFlash, disabling the call to the CRUDController method for cases where I want to customise the message and storing the custom message in the admin (if there is one) so that I can retrieve it in the controller, before re-enabling the call to the CRUDController afterwards.
I see three possible clean resolutions to this:
I prefer option 3... is there any reason why this was not done at the same time as #7761 ?