I am looping through a list of urls and am trying to catch an exception whenever a web request fails but only the first catch block runs but subsequent blocks don’t run even though all of the urls return a 404 error.
I am looping through a list of urls and am trying to catch an exception whenever a web request fails but only the first catch block runs but subsequent blocks don’t run even though all of the urls return a 404 error.
Hi, and welcome to Community,
From your screenshot above, it seems like you’re handling the exception in the Catch Exception
right underneath the web request.
Once an exception has been caught, it will not continue to other Catch Exception
blocks. If you want that behavior, you’ll have to Throw Exception
at the end of your Catch Exception
, so that it can be caught by the next Catch Exception
in the program flow.
When an error occurs in an action node, normal execution of the action will stop, and Appfarm will look for a Catch Exception Action Node. It will first look downward on the same level, then go up one level to look for it there (top-down), and so on. When it finds a catch block that meets the criteria of the error, the catch will execute whatever is defined inside it and then resume execution starting with the node directly after the catch (unless you use end execution or some other flow-changing action).
Hope that helps
// Erik
Hello Erik!
Not sure if we understand each other correctly.
What we are trying to do is iterate through all the Webhooks, send a request and catch potential errors for each of them. Let’s say we have 10 Webhooks, if an error is caught in the second iteration, we want to send a notification and then continue iterating through the rest of the Webhooks and do the same for those as well.
As you can see in the console, it catches an exception in the first iteration and logs to console as expected, but in the second iteration it does not catch the exception and log to console.
Hello again Erik,
I think we might have found the issue. As you can see on the screenshot, it actually logs to console twice, but within iteration 1, which made us believe the exception did not work in iteration 2. But if we store the URL in an object instead, we can see that it actually ran the second exception as well, so it’s all good
The console logging is strange tho, do you have any idea why that happens?
Hi Sigve. As you’re saying there seems to be a logging issue when the catch exception action node is used. I will create a challenge for it so that it can be adressed in the future. Thank you for your feedback!