Error when using Throw activity (Throw Faulted)

code

#1

Hello,

I’m using the Throw activity in order to get out of a For each with a specific business rule.
My throw activity is set like this: new UiPath.Core.BusinessRuleException(“Error in data”)

All my business throw are build like this, but there is one which don’t seems to work as intented, When i Run it and reach it I obtain this error: “Object reference not set to instance of an object

I don’t understand why it seems to work on every throw execpt this one (again, they are identical).
Is anyone encounter this issue and get passed it ?

Thank you for your time/help


Undocumented activity: Throw
Handling run-time error from the Application being automated using UiPath
#2

Hi @Peter

To make this more simpler, you can use Microsoft Activites as well :slight_smile:

  1. Create Exception (Available in Microsoft->Activities->Create Exception) -When you will drag this activity you will get a prompt to select exception type :slight_smile:
    You can pass Your Custom Exception Message in Message property and assign result into a variable. then use Throw Activity and pass the result variable.

InnerException Property is “Gets the Exception instance that caused the current exception.”.

and by following your way : use this new BusinessRuleException(“tst”).

Let me know, if you still have some doubts on it.

Regards…!!
Aksh


#3

Thanks for the answer @aksh1yadav,

Unfortunately, i don’t have access to the Create Exception activity, have download the Microsoft activities extensions, my client have the Studio community to develop , what package should I download in order to get that ?

Another thing, i have ran some tests, turns out none of my throw are working anymore, they were working perfectly fine until last night.
I have tried to create a variable exception with new BusinessRuleException(“error)” and put that variable in the Throw, but the throw still got faulted.


#4

Use Assign activity and select the datatype as uipath.core.BussinessRuleException and then assign your message.

and to install Microsoft activities extension hit Ctrl+p and type Microsft.Activities.Extension and search it and install it and restart your uipath studio.

Regards…!!


#5

I have tried that technique, and I still got the same Object reference error.

Here what i have tested:


and this

Another thing, My UiPath community version reset itself every time it got closed, so i can’t get a package, shut it and reopen, I have to re download it. it is a kown issue ? or should I change my Studio ?

Regards.
Peter


#6

@Lavinia @badita please guide on this.

Regards…!!
Aksh


#7

@Gabriel_Tatu …have heard about something like this?


#8

are you sure you start Studio from its shortcut and not from the installer (.exe file) itself?


#9

Hi,

Yes i use the shortcut on my desktop and the one in the Start menu.
I got the same behavior.

Regards.
Peter


#10

I faced the same issue. Each time ‘throw’ activity executed in my sequence gave message as “Throw Faulted”.
However this problem was resolved when I moved it outside the try-catch block.


#11

Just following up on this with my personal experience in case anyone was left hanging. When I add a “Throw” activity in a Try section, and specify something like new UiPath.Core.BusinessRuleException(“This is what went wrong”) as the throw’s “Exception” field, it fires and is caught just fine.