Throw
System.Activities.Statements.Throw
The "Exception - Throw" activity in AutomatR is used to explicitly throw an exception within a workflow. This activity allows you to create and throw custom exceptions at specific points in your automation process. Throwing exceptions is a way to indicate that something unexpected or erroneous has occurred during the execution of the workflow.
Properties
Name | Description |
---|---|
Misc | |
Display Name | The display name of the activity. A display name is automatically generated when you indicate a target. |
Exception | Specifies the exception that will be thrown. You can create a custom exception object or use predefined exceptions from the .NET Framework, such as System.Exception. Variables containing the exception object or type. |
The "Exception - Throw" activity is instrumental in controlled exception handling scenarios. By explicitly throwing exceptions, you can communicate specific error conditions to higher-level catch blocks or to the overall error-handling mechanism in your automation workflow.
Here's an example of how you might use the "Exception - Throw" activity:
Try
// Some workflow activities
If (condition) Then
Throw New BusinessRuleException("A business rule was violated.")
End If
// Continue with other activities
Catch BusinessRuleException
// Handle the specific business rule exception
Catch System.Exception
// Handle other types of exceptions
LogMessage("An unexpected error occurred.")
Throw // Rethrow the exception for higher-level handling
End Try
In this example, the "Throw" activity is used to throw a custom BusinessRuleException when a specific condition is met. This exception is then caught and handled within the same workflow or propagated to higher-level catch blocks for further handling.