Table of Contents

Struct ErrorHandlerState

Namespace
RDCore.SDK.Runtime.Shared
Assembly
RDCore.SDK.dll

The hidden per-activation state that gives On Error/Resume meaning (MS-VBAL §5.4.4): every activation carries exactly one of these (not one per block-opening instruction, the way With/Select/For hidden state is), since an On Error statement changes the activation's policy going forward, not a lexically-scoped value.

public readonly record struct ErrorHandlerState : IEquatable<ErrorHandlerState>
Implements
Inherited Members

Constructors

ErrorHandlerState(ErrorHandlingMode, int?, IVBRaisableError?, int?, int?, ErrorHandlingMode)

The hidden per-activation state that gives On Error/Resume meaning (MS-VBAL §5.4.4): every activation carries exactly one of these (not one per block-opening instruction, the way With/Select/For hidden state is), since an On Error statement changes the activation's policy going forward, not a lexically-scoped value.

public ErrorHandlerState(ErrorHandlingMode Mode, int? HandlerTarget, IVBRaisableError? ActiveError, int? FaultStatementOffset, int? HandlerEntry = null, ErrorHandlingMode AfterHandling = ErrorHandlingMode.GoTo)

Parameters

Mode ErrorHandlingMode

The activation's current error-handling policy.

HandlerTarget int?

For GoTo: the resolved offset to branch to on an error. While a handler runs (HandlerEntry), the offset the policy after it branches to, when AfterHandling is GoTo. Unused otherwise.

ActiveError IVBRaisableError

The error a handler most recently caught, if any: cleared by a Resume statement, or an On Error GoTo -1. Resume with no active error is MS-VBAL §5.4.4.2 error 20, "Resume without error".

FaultStatementOffset int?

The offset of the instruction whose execution raised ActiveError: what a bare Resume re-executes, and what Resume Next continues past.

HandlerEntry int?

For an activation that is running the handler an On Error GoTo caught an error with: the offset of the handler, until a Resume or an On Error GoTo -1 ends it. Kept apart from HandlerTarget, which is then where the next error goes once the handler is over, and which an On Error statement the handler runs changes. null when no handler is running.

AfterHandling ErrorHandlingMode

While a handler runs (HandlerEntry): the policy once it is over - ended by a Resume, or an On Error GoTo -1. An On Error statement the handler runs sets it, and nothing more: the error is still the one being handled, which the handler can still resume, and a second error still propagates (MS-VBA, Excel-verified, oracle\s53). GoTo the handler's own label until then.

Fields

Disabled

The state every activation starts with: no handler active, no active error.

public static readonly ErrorHandlerState Disabled

Field Value

ErrorHandlerState

Properties

ActiveError

The error a handler most recently caught, if any: cleared by a Resume statement, or an On Error GoTo -1. Resume with no active error is MS-VBAL §5.4.4.2 error 20, "Resume without error".

public IVBRaisableError? ActiveError { get; init; }

Property Value

IVBRaisableError

AfterHandling

While a handler runs (HandlerEntry): the policy once it is over - ended by a Resume, or an On Error GoTo -1. An On Error statement the handler runs sets it, and nothing more: the error is still the one being handled, which the handler can still resume, and a second error still propagates (MS-VBA, Excel-verified, oracle\s53). GoTo the handler's own label until then.

public ErrorHandlingMode AfterHandling { get; init; }

Property Value

ErrorHandlingMode

FaultStatementOffset

The offset of the instruction whose execution raised ActiveError: what a bare Resume re-executes, and what Resume Next continues past.

public int? FaultStatementOffset { get; init; }

Property Value

int?

HandlerEntry

For an activation that is running the handler an On Error GoTo caught an error with: the offset of the handler, until a Resume or an On Error GoTo -1 ends it. Kept apart from HandlerTarget, which is then where the next error goes once the handler is over, and which an On Error statement the handler runs changes. null when no handler is running.

public int? HandlerEntry { get; init; }

Property Value

int?

HandlerTarget

For GoTo: the resolved offset to branch to on an error. While a handler runs (HandlerEntry), the offset the policy after it branches to, when AfterHandling is GoTo. Unused otherwise.

public int? HandlerTarget { get; init; }

Property Value

int?

IsHandling

Whether a handler is running: an On Error GoTo caught an error, which no Resume or On Error GoTo -1 ended yet.

public bool IsHandling { get; }

Property Value

bool

Mode

The activation's current error-handling policy.

public ErrorHandlingMode Mode { get; init; }

Property Value

ErrorHandlingMode

Methods

HandlingOver()

The policy once the running handler is over (AfterHandling, HandlerTarget): no error active, and none being handled. When no handler is running (IsHandling), there is nothing to end: the state as it is.

public ErrorHandlerState HandlingOver()

Returns

ErrorHandlerState