Use Try Catch in-line (not activity)

Hi, I have the expression below that might throw an error if none found.

childrenDownload.First(Function(x) x.get("text").ToString = "Download")

However, instead of using a Try Catch block, what’s the syntax to write it all in one assign activity? Iferror() doesn’t seem to work unfortunately. I’m looking for something like this:

result = try childrenDownload.First(Function(x) x.get("text").ToString = "Download") catch exception, result = nothing end try

Is this possible? To reiterate, I don’t want to use a Try Catch activity, I want it in-line

as you want return null/nothing in case of a item is not present you could use FirstOrDefault

1 Like


Great, that works for an alternative to .first. What about if I’m using .where()? Ex: myArray.where(function(x) x = “not found”)

So I don’t have to surround every linq expression with a possible non-hit with try catches

1 Like

have a check below:


This is EXACTLY what I’m looking for, thank you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.