Can I use THROW in a Catch Block?

Hello all!

Basically, I’m using a Studio template that has built-in error handling; all of my XAMLs are contained within an upstream catch block, so anything I throw within my process XAMLs will be caught accordingly.

In my TryCatch, I really “Catch” two types of exceptions; System and BusinessRuleException (the latter only when applicable). Regarding System exceptions, I originally was using an error-level log and inserting the message as exception.Message, but the bot obviously is moving past that and not stopping as it would when an error is thrown.

So, I would like to replace that log message with a “Throw” activity where I’d insert something like New Exception(exception.Message) so the bot would actually skip to the next transaction.

image

Is this acceptable? Thoughts on this?

[EDIT]
To specify, I do NOT use a “throw” activity in the Try block for system exceptions

Hi @jonathan.traeger,

You can use rethrow activity. It requires no input.

Regards,
Harshith

Excellent, and that’ll accomplish the same thing? And would I need to log an error message before that?

I should have been more specific, I want to specify that I am NOT throwing an exception in the Try block for the system exception - just (in this case) in the catch block

Yes, It will automatically capture the the exception and throw. You need not mention exception.Message.

1 Like

Alright fantastic, thank you

1 Like

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