New BusinessRuleException("Input Data Invalid") explanation


I wanted to understand the meaning of the below code :
new BusinessRuleException(“Input Data Invalid”)

My understanding is : BusinessRuleException is a variable of type “exception”.
So I am expecting it will catch the exception.

But what does the word “new” do? Why do we need it.
Thanks !

Hi @Vidya_Srinivasan,
“New” in this context is just declaration of new object. You need to create it and include error inside it’s value so it will return this object with exact error.

1 Like

Hi @Vidya_Srinivasan

So, If I’m to elaborate more on @Pablito’s answer, when declaring an object in .net, it is required to create a new object of that type. So, object can have many types, and exception is one of them. Without having a new object created, you will not be able to assign anything to it. If you try, it will simply through out an error as you are trying to do something with not really a created object, but something not created, in other words, a NULL :slight_smile:
This is kind of similar to other types like Arrays, Lists etc. For those we use the same pattern…
New List(Of String),
New String (){ }

So in our scenario here, having the New keyword in New BusinessRuleException will create a new object of business rule exception type where you can use it to assign the exception information within the brackets to it.


If i replace BusinessRuleException with a different name and declare it (say CashIn_Invalid_Exception)
why does it show a error.However in case if i use name BusinessRuleException no error is seen.
Why is it so since both BusinessRuleException and CashIn_Invalid_Exception are just variables of type exception

1 Like

Hi Lahiru,

But assign activity works without this new keyword.There also we have variables of some type.

So i m just trying to figure out where all we might need to add new.

1 Like


Just to give you an overview,

Exception is a system or technical exception which you got from the system or the application which is taken from the system or application to show to the user while the business exception is something we can show our own text to the user .

What I mean to say is, Exception type can be a variable we can store the value of the system or application exception. So, define your variable type as business rule exception to give your own text in the assign activity you have in the screenshot @Vidya_Srinivasan:slight_smile: hope this help you

1 Like


Sorry for the late reply. Just got back after a meeting

So Exception is a type that is system defined. It is defined in the .net platform which is used across .net related languages. C# etc. We can see this even in other languages too. So, Business Rule Exception and Application Exception is also one of those other types of exceptions that are built internally to support the requirements of automation. So, if you are to build your own types which you can declare as
new MyCustomException
Then, you will need to some good amount of programming behind the scenes to get it here. If you are into component building, you can create such exception types to be used within the activities.

However, here we only have the Exception, Business rule and application exceptions which are built in for us. So what you tried to do is doable, with some good about of coding as I explained. But here, we only use the available stuff. But, you can customize those to show our own types of exception messages which can be mentioned within the brackets… There you can create a string message that contain multiple information about the error. You can use String Formatting to include many like that…