Struct ErrorHandlerState
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
ModeErrorHandlingModeThe activation's current error-handling policy.
HandlerTargetint?For GoTo: the resolved offset to branch to on an error. While a handler runs (
HandlerEntry), the offset the policy after it branches to, whenAfterHandlingis GoTo. Unused otherwise.ActiveErrorIVBRaisableErrorThe error a handler most recently caught, if any: cleared by a
Resumestatement, or anOn Error GoTo -1.Resumewith no active error is MS-VBAL §5.4.4.2 error 20, "Resume without error".FaultStatementOffsetint?The offset of the instruction whose execution raised ActiveError: what a bare
Resumere-executes, and whatResume Nextcontinues past.HandlerEntryint?For an activation that is running the handler an
On Error GoTocaught an error with: the offset of the handler, until aResumeor anOn Error GoTo -1ends it. Kept apart fromHandlerTarget, which is then where the next error goes once the handler is over, and which anOn Errorstatement the handler runs changes. null when no handler is running.AfterHandlingErrorHandlingModeWhile a handler runs (
HandlerEntry): the policy once it is over - ended by aResume, or anOn Error GoTo -1. AnOn Errorstatement 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
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
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
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
Mode
The activation's current error-handling policy.
public ErrorHandlingMode Mode { get; init; }
Property Value
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()