Document 1inch API errors and error_type for GUI to react on errors

Hi 1inch team,
I am working on 1inch API integration to our wallet app.
I’d like to ask you to document your errors. For e.g. I receive an API error like this:

{"error":"Bad Request","description":"Not enough allowance. Amount: 10000000. Allowance: 0. Spender: 0x111111125421ca6dc452d289314280a0f8842a65","statusCode":400,"meta":[{"type":"amount","value":"10000000"},{"type":"allowance","value":"0"}],"requestId":"712f9d2b-c058-4cc1-af49-83806d1a4a40"}

This error says to the user that he needs to approve some tokens for the contract. I’d like to understand that in the code and and present appropriate action to the user. But the error is hidden inside the ‘description’ field (should I parse the description? what if the GUI multilingual?).

I believe the ‘meta’ field has meaningful info but there is no any description of its format and structure (how to interpret it)
I think if you add an error_type with documented const values (for e.g. ‘ALLOWANCE-NOT-ENOUGH’ for this error), along with documented ‘meta’ values this would help GUI much to process errors from the API.

1 Like