Hi - I have implemented a bunch of external APIs using the API connector.
When the API calls are used as Actions in a workflow, I have error handling in place (e.g. to record the details of the error in my database, and to display an appropriate message).
But when they are used as Data (e.g. to display the results in a table in my app), I can’t work out how to implement the same error handling. For example, how would I record the details of an API error as a new “error” object in my database?
Thanks for your help
That is a great question. I’m not sure it is handled in the same way as an error in an action. What happens if there is an error in the data API call? You might be able to use this event to trigger the action:
So I think that in general, if there’s an error then the place where I’m displaying the data (the table or the repeating group, or the text field) will simply be blank. I don’t think the “unhandled error” trigger will work. When you use that trigger you get this choice (i.e. it suggests it will only catch errors related to workflows).
Furthermore, in the actions which I create under this “unhandled error” workflow, I can’t access the API error response. So, for example, I have no way to record the API error message that came back.
Hello @marketing15
Maybe you could try getting the full response in a hidden group setting the type of content to be the specific call you’re using as a datasource. Then using its values to handle errors.
You could also get the full JSON in a different element and then manipulating it using JavaScript with an “Expression” element from the Toolbox plugin. That way you could get both, the data and the error/status for error handling.
The last method gives you the advantage of triggering events with the JS to Bubble element from the same plugin to make changes to things on your DB
Thanks Juan. Yes, I think that could work. But it feels surprisingly cumbersome and complex for what must be a pretty standard use case. Will give it a go