FriendsOfCake / crud

Production-grade rapid controller development with built in love for API and Search

Home Page:https://crud.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: why does Crud component throw an exception when there's a response?

geoidesic opened this issue · comments

https://github.com/FriendsOfCake/crud/blob/master/src/Controller/Component/CrudComponent.php#L553

It feels to me like the exception system is being used as a render mechanism here instead of for errors... or am I missing something?

I think something like this is okay, as it gives options to the developer on how they handle that exception. Mostly because if the event did return a response, by using an exception the calling code can catch it and still choose to return the response.

Perhaps it could return Throwable, but then the calling code would have nothing to catch? However then it would change the return type of the method. So using an exception here allows both cases to be workable.

Ok tx.