Closed MannikJ closed 2 years ago
These days it's easy to render specific exceptions using the Laravel exception handler: https://laravel.com/docs/8.x/errors#rendering-exceptions
VatCalculator these days throws the VATCheckUnavailableException
exception when the VIES API is down. You can catch this in the handler referenced above and render your custom response.
https://github.com/driesvints/vat-calculator#validate-eu-vat-numbers
We use this wonderful package with the built-in API routes via ajax from vue. We just call
get
on the route/vatcalculator/calculate
which works fine most of the time, but sometimes - as often discussed - there are availability issues with the VIES service so that this request fails. I saw I can activate exception forwarding in the config, but then the whole thing just blows up and I don't know where to handle the exception. I would like to handle this stuff in the backend, preferably without implemeting my own controller, routes, etc. So is there a neat way to integrate custom fallback logic without having to reinvent the wheel?