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?)
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)
Parameters
ModeErrorHandlingModeThe activation's current error-handling policy.
HandlerTargetint?For GoTo: the resolved offset to branch to on an error. Unused otherwise.
ActiveErrorIVBRaisableErrorThe error a handler most recently caught, if any — cleared by a
Resumestatement.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 aResumeends it. Kept apart fromHandlerTargetbecause catching resets the policy, and with it where the next error would go. null when no handler is running.
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. Resume
with no active error is MS-VBAL §5.4.4.2 error 20, "Resume without error".
public IVBRaisableError? ActiveError { 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 ends it. Kept apart from
HandlerTarget because catching resets the policy, and with it where the next error would go. 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. Unused otherwise.
public int? HandlerTarget { get; init; }
Property Value
- int?
Mode
The activation's current error-handling policy.
public ErrorHandlingMode Mode { get; init; }