Error handling
Error handling of API responses is not a part of this module since the main goal is to provide an authentication layer and configured API client, but on this page, you can find useful hints.
When Laravel returns an error of any kind (403, 404, 500, etc), the module will throw this as an exception that has a generic Error
type.
Error type check
This is how you can check what type of error you received
Sometimes, it is not convenient, especially when it comes to validation errors in plenty of forms and components.
Error helper
Here you can get inspiration from error handling specifically for this case and implement it your way.
Create a new composable useApiError
with the following content:
Use it as in the next example to extract all the errors from the response and handle it according to your logic:
Have a good debugging! 😎
Last updated