Learn how to handle errors gracefully without crashing your app
status
field in each response allows you to check the
state of your request (whether successful or otherwise).
validate_vat()
function accepts a vat_number argument which is a user input. This function uses the VatAPI.validate()
method to validate a VAT number.
It uses exception handling to manage the two error kinds that might occur in your app - TypeError and JSON error messages.
This setup works with any Python app(mobile, desktop, web). Also, it can be used with all the API classes and their methods.
Simply replace the required methods and API class where necessary.