02-23-2023 05:25 AM
Issue is inside custom connector ruby code.
Context: I have a list of companies in an array then I am using .each method to loop every company and then hitting an api call on every company.
Problem: Now one api call is failed for a company and code breaks. I don't want code to break, instead I want loop to continue as we use try catch in many languages to prevent breaking of loop. How to acheive the same in Custom Connector SDK using ruby.
Solved! Go to Solution.
02-28-2023 01:33 AM
Ruby exception handling is unfortunately also not supported in the SDK-Code.
03-05-2023 09:11 PM
There is no support for exception handling so I have move this code on the recipe level and then I used repeat action in a parent recipe on my company array and then every action goes to a child recipe where I use monitor block of recipe to handle exception from API. Then I move every error into lookup table.
02-23-2023 06:15 AM
My API call is as below:
02-27-2023 07:36 AM
Hey @bhavesh-patel,
I think this page on ruby loops could be helpful for you: https://www.tutorialspoint.com/ruby/ruby_loops.htm
You can also find more variations of 'each' here: https://docs.workato.com/developing-connectors/sdk/sdk-reference/ruby_methods.html#each
Please let me know if you find your solution within those pages!
Cheers,
Meghan
02-27-2023 08:58 AM
I'm not sure if begin/rescue or catch/throw are supported in a custom connector, but you should give them a try. They aren't supported in the Ruby recipe connector (I tried and confirmed with Workato support) but the connector SDK tends to have broader Ruby support.
https://www.geeksforgeeks.org/ruby-exception-handling/
Here's an example:
companies.each { | company |
x = {}
begin
x.split(';') # example that will throw error
# put your API call here
rescue
puts "error is skipped"
end
}
02-28-2023 01:33 AM
Ruby exception handling is unfortunately also not supported in the SDK-Code.