Open wireblue opened 9 years ago
Really depends on how your controller handles the Handler return value.
If you have a look at the example, you can see that JsonApi\Exception
s are caught and handled appropriately, but it's up to you to implement this logic.
For the me the problem is occuring when I return an ErrorResponse object from my custom handler (eg. ProductsHandler.php) to this project's "Handler.php". This occurs within the "fulfillRequest" method. It hasn't yet returned back to the controller yet, so I'm unable to deal with it there.
Are you suggesting that I should implement my own version of "fulfillRequest", or bypass it completely in my controller?
If it helps anyone else I ended up creating my own "BaseHandler" which extended the \EchoIt\JsonApi\Handler. I changed the "fulfillRequest" to suit my needs and updated my other handlers to extend from my new "BaseHandler".
I feel a fix to the \EchoIt\JsonApi\Handler would be more ideal, so I will leave this issue open and to the discretion of the repo maintainer.
Hi all,
Not sure if this is incorrect usage or a bug, but I'm getting errors when returning error response from my customer handlers.
Example:
Because Handler.php is only looking for instances of "Response" (on Line 84), not ErrorResponse or MultiErrorResponse, it trips up when it tries to load the (non-existent) models.
I'd be happy to submit a simple PR to check for the other two response types, but I didn't know if this was the best way to go about it. Should ErrorResponse and MultiErrorResponse be inheriting from Response instead, or am I "doing it wrong"?
Thoughts?
Kyle