sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Fix handle exception in #7761 #8194

Closed p-golovin closed 4 months ago

p-golovin commented 4 months ago

Return error message from handleModelManagerThrowable

Subject

In #7761 was introduced ability to return custom error message when something goes wrong on persist/update/delete actions with ORM. But it always return null instead of message.

I am targeting this branch, because fix bug in current stable branch.

Changelog

Changed

- CrudController::handleModelManagerThrowable can now return a custom error message to display in the flashbag instead of the generic one from Sonata
VincentLanglet commented 4 months ago

Hi @p-golovin, you misunderstood the way to use this method.

By default Sonata returns null and uses the generic error message to "hide" the implementation details. People might want to not display some ORM internal error message.

But if you want to display such error message you just have to override the handleModelManagerThrowable method the way you did here, but on your personal project