Closed jhoanborges closed 1 year ago
I don't get your Idea behind this. What is the Problem you are trying to solve?
A Custom Exception is already implemented: OdooException You can catch this exception with a catch(OdooException $eception){...} block and handle the response accordingly.
You can access the underlying message with the standard exception getMessage() method.
If you like to always get a custom json response whenever a OdooException occours you can implement a custom Renderer for this kind of exception. See: https://laravel.com/docs/10.x/errors#rendering-exceptions
I was having troubles trying to show errors on the API because all is managed inside the library. So i created a new Laravel Exception to handle that message and be able to catch it through an api response.
So now the exception response will be like this: