Throwing String Exception

Is it possible to throw a string or catch only new exceptions. I know you can make a new exception, new exception(“Message”). But I would like to be able to throw a string based on different situations and then catch it so if there is another error I can catch that separately. Is there a way to do this.

1 Like

You can define new exceptions, and in the catch block, catch that particular exception.

Thank you for the reply, I may be misunderstanding. I would like be able to throw multiple exceptions that contain different messages but catch them all in the same catch. Then have a separate catch for everything else. Ideally only having two catches. Is this possible?

Would be possible creating a new class extending System.Exception. Or inside Catch block use a Switch Statement evaluating the text inside Exception and taking an action according that.

Hi @Jacob_Frost

You can create separate exceptions (new Exception()), and in the Try/Catch block simply catch ‘System.Exception’. This should catch any type of exception thrown within the Try.

@Jacob_Frost

Yes it’s possible. We have to use nested Try Catch block for this.

In inner try block, throw multiple exceptions and corresponding catch block will catch any exception.

HI @Jacob_Frost,

you are able to create custom exceptions using Throw activity. First make Try Catch seqence secondly in Try put Throw with New Exception(“your custom msg”) then catch in Catch block by assigining it to yourExceptionVariable = exception

Regards,
Aleksander