What is an Exception?

You are currently viewing What is an Exception?

Overview

An exception represents an error that occurs during the execution of an automation. There are two main types of exceptions, Application Exceptions and Business Rule Exceptions, explained below.

An exception object contains information about the error, including its type and the state of the program when the error occurred. 

Creating an exception object and handing it to the system is called throwing an exception

How do you Throw an Exception?

Exceptions can occur in two ways; naturally, when something disrupts the normal flow of the automation, or manually thrown using the Throw or ReThrow activities. To learn how to throw an Exception, please check out our tutorials on throwing exceptions:

  • How to Throw an Exception
  • How to Throw a Business Rule Exception
  • How to ReThrow an Exception
There are two main types of exceptions, Application Exceptions and Business Rule Exceptions:

What is an Application Exception?

An application exception is an error related to a technical issue. Some examples include an application that failed to start or a website not responding.

Retrying can resolve the issue.

Application Exceptions can be both naturally occurring (an activity within the workflow fails) or manually created with the Throw or Rethrow activity discussed here.

What is a Business Rule Exception?

A Business Rule Exception is an error related to the data the automation depends on. Examples include a scraped Excel file in the incorrect format, or an email sent from the business group with the wrong attachment.

Retrying does not solve the issue. Other courses of action would be more appropriate, like notifying the business group via an email that the automation failed.

Business Rule Exceptions can only occur if they are manually added to the workflow through the Throw and Rethrow activities discussed here. These exceptions cannot occur if an activity within the workflow fails.

Commonly Used Properties

The following are some commonly used properties for Exceptions. A property is a characteristic or attribute of an object (i.e. Exception). To learn more about properties, click here

HelpLink - Gets a link to the help file associated with this exception

Example Property Return Description Return Type
Exception.HelpLink
Help File
String

InnerException - Gets the exception instance that caused the current exception

Example Property Return Description Return Type
Exception.InnerException
Inner Exception
String

Message - Gets the message that describes the current exception

Example Property Return Description Return Type
Exception.Message
Exception Message
String

Source - Gets the name of the application that caused the error

Example Property Return Description Return Type
Exception.Source
Application Name
String

TargetSite - Gets the method that throws the current exception

Example Property Return Description Return Type
Exception.TargetSite
Method Name
String

StackTrace - Gets a string representation of the immediate frames on the call stack

Example Property Return Description Return Type
Exception.StackTrace
Immediate Frames
String

Hresult - Gets or sets HRESULT, a coded numerical value assigned to a specific exception

Example Property Return Description Return Type
Exception.Hresult
HRESULT
Integer (Int32)

Commonly Used Methods

The following are some commonly used methods for Exceptions. Methods are actions that objects (i.e. Exceptions) can perform. To learn more about methods, click here

GetBaseException - Gets the exception that is the root cause

Example Property Return Description Return Type
Exception.GetBaseException
Root Cause
String

GetType - Gets the data type

Example Property Return Description Return Type
Exception.GetType
Data Type
Type

ToString - Converts the exception to a string

Example Property Return Description Return Type
Exception.ToString
String of Exception
String