10.2 Global Exception Handler Architecture & ErrorAction Directives

Key Takeaways

  • A project can have one Global Exception Handler, it is not available in library projects, and any workflow except Main.xaml can be set as the handler.

  • The handler has two arguments: errorInfo (In) with the Exception, ActivityInfo, and RetryCount, and result (Out) with the ErrorAction to take.

  • ErrorAction values: Continue rethrows the exception, Ignore continues from the next activity, Retry re-runs the failed activity, and Abort stops after the handler runs.

  • The handler runs for each activity in the call stack, but not for activities placed directly in a Try block; group them in a Sequence inside the Try.

  • Guard Retry with errorInfo.RetryCount to avoid endless loops, and keep transaction-level recovery in REFramework.

Last updated: September 2026

10.2 Global Exception Handler Architecture & ErrorAction Directives

Core Concept: The Global Exception Handler (GEH) is an enterprise project-level architectural safety net in UiPath Studio. Configured as a specialized .xaml workflow, the Global Exception Handler runs when an activity throws an execution error and decides what happens next. By inspecting rich execution telemetry via the errorInfo input argument, the handler dynamically directs the workflow runtime using ErrorAction directives—enabling in-place activity retries, controlled process aborts, silent error suppression, or upward exception rethrowing.

In enterprise automation environments, robust error handling is the primary determinant of production reliability. While local TryCatch containers allow developers to manage expected, anticipated errors at specific transaction boundaries, unexpected application glitches—such as transient network timeouts, third-party desktop rendering delays, or intermittent background OS resource locks—can occur anywhere within a process. The Global Exception Handler provides a centralized, deterministic framework to manage these unhandled exceptions without requiring developers to wrap every single activity in defensive boilerplate code.


1. Global Exception Handler Architecture & Invocation Lifecycle

The Global Exception Handler operates at the compilation root of a UiPath Studio project. It is created using the specialized Global Handler workflow template (typically named GlobalHandler.xaml).

What happens when an activity throws an error (Global Exception Handler set)
[Activity throws an exception]
              │
              ▼
    [Global Exception Handler runs for that activity]
    (not for activities placed directly in a Try block;
     group them in a Sequence inside the Try)
              │
              ▼
    [Inspect errorInfo, assign an ErrorAction to result]
              │
    ┌─────────┼──────────┬──────────────┐
    ▼         ▼          ▼              ▼
  Retry     Ignore    Continue        Abort
  (re-run   (go to    (rethrow: an    (stop after the
  activity) next      enclosing Catch handler finishes)
            activity) can handle it)

Key Architectural Constraints

  • Singleton Per Project: An automation project can have at most one Global Exception Handler set at any given time. Any workflow can be flagged as the handler except Main.xaml.
  • Project Scope Only: The Global Exception Handler can only be created inside standard Automation Process projects. It is not supported in Library projects because libraries are meant to be consumed as modular dependencies where exception bubbling must remain under the control of the consuming workflow.
  • Activation: Create one from New > Global Handler on the Design ribbon, or right-click an existing workflow in the Project panel and select Set as Global Handler. The Project panel marks the handler with its own icon.
  • Invocation Trigger: The handler runs when an activity in the project throws an error. UiPath documents two details that surprise many developers:
    • In nested activities, the handler executes for each activity in the call stack.
    • It does not execute for activities directly encapsulated in a Try Catch, unless they are contained in another activity. UiPath's note puts it the other way round: when a project uses a Try Catch, group the activities into a Sequence inside the Try container, otherwise the Global Exception Handler does not execute.
    • So an error thrown by an activity inside a Sequence in the Try block reaches the handler first. The value it returns decides what happens: Continue rethrows the exception, and the enclosing Catch can then handle it.

2. Handler Arguments: errorInfo and result

The interface between the UiPath execution engine and GlobalHandler.xaml is strictly defined by two reserved workflow arguments:

+--------------------------------------------------------------------------------+
|                         GLOBAL HANDLER ARGUMENT CONTRACT                       |
|                                                                                |
|  [Workflow Engine] ─────► In: errorInfo (ExceptionHandlerArgs) ─────► [GEH]   |
|                                                                         │      |
|  [Workflow Engine] ◄───── Out: result (ErrorAction) ◄───────────────────+      |
+--------------------------------------------------------------------------------+

1. In Argument: errorInfo (UiPath.Core.ExceptionHandlerArgs)

The errorInfo argument carries comprehensive diagnostic metadata regarding the failure context:

  • errorInfo.Exception (System.Exception): The exact exception object thrown by the failing activity. Exposes standard .NET diagnostic properties:
    • errorInfo.Exception.Message: The human-readable error description (e.g., "Cannot find the UI element corresponding to this selector").
    • errorInfo.Exception.Source: The internal source module or activity package that threw the fault.
    • errorInfo.Exception.StackTrace: The full chronological stack trace indicating the precise execution path leading to the failure.
    • errorInfo.Exception.InnerException: Any underlying nested exception wrapped by the primary fault.
  • errorInfo.ActivityInfo: Identifies the activity that faulted:
    • errorInfo.ActivityInfo.Name: The display name of the activity that threw the exception, which UiPath's own example assigns to a variable and logs.
  • errorInfo.RetryCount (System.Int32): A zero-based integer tracking how many times the Global Exception Handler has already retried this specific failed activity. On the initial failure, errorInfo.RetryCount equals 0. If the handler issues an ErrorAction.Retry directive and the activity fails again on the subsequent attempt, errorInfo.RetryCount increments to 1, then 2, and so forth.

2. Out Argument: result (UiPath.Core.ErrorAction)

The result argument is an enumeration value returned by GlobalHandler.xaml to the workflow engine, commanding it on how to proceed.


3. The ErrorAction Enum Directives: Deep Dive

The ErrorAction enumeration defines four distinct directives that dictate runtime behavior following an unhandled error:

ErrorAction Enumeration Directives
├── ErrorAction.Retry    ──► Re-executes the failed activity in-place from scratch
├── ErrorAction.Abort    ──► Terminates the entire process immediately with a fatal error
├── ErrorAction.Ignore   ──► Suppresses the error and proceeds to the very next activity
└── ErrorAction.Continue ──► Rethrows the exception up the standard call stack

1. ErrorAction.Retry

  • Operational Mechanics: Instructs the workflow engine to re-execute the exact activity that failed.
  • Execution Boundary: The retry occurs strictly at the activity level. The workflow does not restart from the beginning of the workflow file, nor does it re-execute preceding activities in the container sequence.
  • Retry Counter Behavior: Re-executing the activity increments errorInfo.RetryCount by 1. If the retried activity fails again, the Global Exception Handler is reinvoked with the incremented RetryCount.
  • Enterprise Best Practice: Never issue ErrorAction.Retry unconditionally; doing so creates an infinite execution loop if an application is permanently unresponsive. Always guard the retry directive with a conditional check against a maximum retry threshold (typically 2 or 3 retries):
    If errorInfo.RetryCount < 3 Then
        result = ErrorAction.Retry
    Else
        result = ErrorAction.Abort
    End If
    

2. ErrorAction.Abort

  • Operational Mechanics: UiPath documents Abort as: the execution stops after running the current Global Exception Handler.
  • Status in Orchestrator: The execution stops after the Global Exception Handler finishes running, and the error ends the job.
  • Use Case: Used when a permanent, fatal infrastructure failure occurs—such as database connectivity loss, complete application crash, invalid credentials, or when an activity has exhausted its maximum allowable retry count.
  • Best Practice: Before setting result = ErrorAction.Abort, the handler should execute diagnostic actions: capturing a desktop screenshot, logging a fatal audit entry, and dispatching alert notifications to operations teams.

3. ErrorAction.Ignore

  • Operational Mechanics: Commands the workflow engine to suppress the exception entirely, skip the failed activity, and immediately proceed to the next activity in the sequence.
  • Analogy: Identical in behavior to the legacy Visual Basic On Error Resume Next directive.
  • Critical Architectural Warning: ErrorAction.Ignore is inherently hazardous in enterprise automations. If Activity 1 (Extract Customer Balance) fails and is ignored, Activity 2 (Calculate Tax on Customer Balance) will execute against an uninitialized or null variable, triggering downstream null reference exceptions or corrupting transactional financial records.
  • Valid Use Case: Strictly restricted to non-critical, optional side-effects where failure has zero impact on downstream data integrity—such as dismissing an optional promotional banner, closing a non-essential tooltip, or writing a secondary telemetry log.

4. ErrorAction.Continue

  • Operational Mechanics: Instructs the runtime to rethrow the exception and re-engage the standard exception bubbling hierarchy.
  • Propagation Behavior: The exception escapes the Global Exception Handler and travels up the call stack. If any higher-level caller workflow contains an enclosing TryCatch block, that outer TryCatch will catch the error. If no parent TryCatch exists, the process terminates fatally with the original exception.
  • Enterprise Use Case: Used when the Global Exception Handler is utilized as a centralized diagnostic logger (e.g., capturing a timestamped screenshot and writing custom audit metadata to an external SIEM tool), while delegating actual recovery or business decision-making to calling parent workflows.

4. Enterprise Design Patterns for GlobalHandler.xaml

Production implementations of the Global Exception Handler incorporate sophisticated diagnostic and defensive logic:

' Decision logic written as VB.NET for readability. In GlobalHandler.xaml you build it
' with If, Assign, Log Message, and Take Screenshot activities.
' Step 1: Capture Diagnostic Screenshot on First Failure
If errorInfo.RetryCount = 0 Then
    Dim screenshotPath As String = Path.Combine(in_LogFolder, $"Error_{errorInfo.ActivityInfo.Name}_{DateTime.Now:yyyyMMdd_HHmmss}.png")
    ' Execute Take Screenshot and Save Image activities
End If

' Step 2: Differentiate Exception Types and Determine Action
If TypeOf errorInfo.Exception Is UiPath.Core.SelectorNotFoundException OrElse
   TypeOf errorInfo.Exception Is System.TimeoutException Then
    
    ' Transient UI delay: retry up to 3 times
    If errorInfo.RetryCount < 3 Then
        Console.WriteLine($"[GEH RETRY] Activity '{errorInfo.ActivityInfo.Name}' failed. Attempting retry {errorInfo.RetryCount + 1} of 3.")
        result = ErrorAction.Retry
    Else
        Console.WriteLine($"[GEH ABORT] Activity '{errorInfo.ActivityInfo.Name}' exceeded maximum retries. Aborting execution.")
        result = ErrorAction.Abort
    End If

ElseIf TypeOf errorInfo.Exception Is System.Security.Authentication.AuthenticationException OrElse
       TypeOf errorInfo.Exception Is System.IO.FileNotFoundException Then
    
    ' Permanent Configuration / Security Fault: Abort immediately without retrying
    Console.WriteLine($"[GEH FATAL] Permanent fault encountered in '{errorInfo.ActivityInfo.Name}': {errorInfo.Exception.Message}. Immediate abort.")
    result = ErrorAction.Abort

Else
    ' Unhandled generic system fault: Log and rethrow to parent caller
    result = ErrorAction.Continue
End If

Telemetry Enrichment Best Practices

  1. Dynamic Delay Before Retry: To allow an unresponsive application window time to render, insert a short Delay activity (e.g., 2 to 5 seconds) inside GlobalHandler.xaml before assigning ErrorAction.Retry.
  2. Selective Activity Filtering: Inspect errorInfo.ActivityInfo and the exception type. If the failing activity is a sensitive transactional operation (such as Execute NonQuery inserting a ledger line), retrying in-place could create duplicate database records. Filter out non-idempotent activities and abort instead.
  3. Audit Trail Logging: Always log errorInfo.ActivityInfo.Name, errorInfo.RetryCount, and errorInfo.Exception.Message to Orchestrator at the Warn or Error logging level.

5. Architectural Comparison: GEH vs. REFramework TryCatch

Enterprise architects must understand how the Global Exception Handler interacts with the Robotic Enterprise Framework (REFramework):

Architectural Layering: REFramework vs. Global Exception Handler
+--------------------------------------------------------------------------------+
|  REFramework Process.xaml (Transaction Scope)                                  |
|  +--------------------------------------------------------------------------+  |
|  | TryCatch (Enclosing Business Logic)                                      |  |
|  |  - Try: Navigate -> Click -> Extract -> Submit                          |  |
|  |  - Catch BusinessRuleException: Mark Queue Item 'Failed - Business'      |  |
|  |  - Catch System.Exception: Close Apps -> Init State -> Retry Transaction  |  |
|  +--------------------------------------------------------------------------+  |
|  * If a GEH is set, it runs first for activities grouped inside the Try.   |  |
|  * Only if it returns Continue does the local Catch receive the error.      |  |
+--------------------------------------------------------------------------------+
                                       │
            (Runs for activity errors in the call stack)
                                       ▼
+--------------------------------------------------------------------------------+
|  GlobalHandler.xaml (Process Safety Net)                                       |
|  - Decides Retry, Ignore, Continue, or Abort for the failing activity          |
|  - Activity-level retry in place (no app restart)                              |
|  - Final safety barrier before unexpected robot crash                          |
+--------------------------------------------------------------------------------+

Key Differences Table

Architectural DimensionGlobal Exception Handler (GEH)REFramework Process.xaml TryCatch
Architectural ScopeProcess-wide global safety netLocal transaction boundary
Interception PointRuns for the failing activity (and each activity in the call stack) and returns an ErrorActionExceptions thrown inside the Try block of the transaction
Retry GranularityActivity-level: Retries the single failing activity in-placeTransaction-level: Restarts applications and retries the entire transaction
Application State RecoveryNo application reset (leaves UI in current state)Executes CloseAllApplications / KillAllProcesses and returns to Init
Queue Item ImpactDoes not interact directly with Orchestrator queuesUpdates Queue Item status (Successful, Failed, Retried)
Typical TargetUnattended desktop glitches, unattended process crashesBusiness logic validation, API failures, transactional data faults
Loading diagram...
Global Exception Handler invocation and ErrorAction routing
Test Your Knowledge

A project has a Global Exception Handler. An activity fails inside a Sequence that sits in the Try block of a Try Catch whose Catch handles System.Exception. According to UiPath's documentation, what happens?

A

The Global Exception Handler never runs when any Try Catch exists in the project.

B

The Global Exception Handler runs first for the failing activity; if it returns Continue, the exception is rethrown and the enclosing Catch can handle it.

C

The exception is silently ignored because two handlers compete.

D

The job is always aborted without running the Catch.

Test Your Knowledge

In GlobalHandler.xaml, what is the exact runtime behavior when the developer sets the output argument result = ErrorAction.Ignore?

A

The workflow engine suppresses the exception, skips the failed activity, and immediately resumes execution with the next activity in the sequence.

B

The workflow engine retries the failed activity up to the default maximum retry count of three.

C

The workflow engine immediately terminates the automation and marks the Orchestrator job as Successful.

D

The workflow engine rethrows the exception and executes any parent TryCatch catch blocks.

Test Your Knowledge

How does the retry mechanism of the Global Exception Handler differ from the retry mechanism implemented in the Robotic Enterprise Framework (REFramework)?

A

The Global Exception Handler retries the entire process from Main.xaml, whereas REFramework only retries individual activities.

B

The Global Exception Handler only works with Orchestrator Queue items, whereas REFramework handles file-based retries.

C

The Global Exception Handler can only retry an activity once before crashing, whereas REFramework can retry infinitely.

D

The Global Exception Handler retries the specific failed activity in-place without resetting application state, whereas REFramework catches transaction-level exceptions, closes and re-initializes all applications, and re-executes the transaction from the beginning.

Sections you finish are checked off in the contents.