Table of Contents

Interface ISessionErrorState

Namespace
RDCore.SDK.Runtime.Abstract.Execution
Assembly
RDCore.SDK.dll
public interface ISessionErrorState

Properties

Current

The most recent run-time error, or null when there is none — the state Err.Number reports as 0.

IVBRaisableError? Current { get; }

Property Value

IVBRaisableError

Description

MS-VBAL §6.1.3.2.2.1 Err.Description: what went wrong, in words.

string Description { get; set; }

Property Value

string

Remarks

A raise sets it to the raised error's own description. Source sets it both before an Err.Raise that omits one, and from inside a handler.

HasError

Whether an error is current. Err.Number <> 0, in source terms — and exactly that, so source assigning Number makes an error current the same way raising one does.

bool HasError { get; }

Property Value

bool

HelpContext

MS-VBAL §6.1.3.2.2.2 Err.HelpContext.

int HelpContext { get; set; }

Property Value

int

Remarks

ℹ️ Carried so that source can round-trip what it sets. The help system it indexes is a legacy proprietary one, and is out of scope of this implementation.

HelpFile

MS-VBAL §6.1.3.2.2.3 Err.HelpFile.

string HelpFile { get; set; }

Property Value

string

Remarks

ℹ️ Carried so that source can round-trip what it sets. The help system it names is a legacy proprietary one, and is out of scope of this implementation.

LastDllError

MS-VBAL §6.1.3.2.2.4 Err.LastDllError: the system error code of the last call into a dynamic-link library. Read-only, and 0 for as long as a Declared procedure cannot be executed at all.

int LastDllError { get; }

Property Value

int

LineNumber

🎯 RD-VBAL The line number the current error was raised at - the nearest line-number label at or before the faulting statement, or 0 when none precedes it. What Erl reports.

long LineNumber { get; }

Property Value

long

Remarks

🎯 long rather than MS-VBA's own resolution, deliberately: MS-VBA reports Erl as a ushort and wraps around on anything that does not fit, so a program numbered past 65535 is told it faulted somewhere it did not. RD-VBA widens it so that every legal line number label is representable. A named label never sets it; only a label spelled as decimal digits does.

Number

MS-VBAL §6.1.3.2.2.5 Err.Number: the code of the current error, 0 when there is none.

int Number { get; set; }

Property Value

int

Source

MS-VBAL §6.1.3.2.2.6 Err.Source: the object or application that originally generated the error.

string Source { get; set; }

Property Value

string

StackTrace

🎯 The call stack the current error was raised on, captured at the raise. Empty when no error is current, or when source made one current by assigning Number rather than by raising it.

VBStackTrace StackTrace { get; }

Property Value

VBStackTrace

Remarks

RDCore's own, not MS-VBAL's — VBA can say what an error was but never where it came from. It has to be captured rather than derived on demand: by the time a handler reads it, the activations it describes have been unwound.

Methods

Clear()

Clears the current error.

bool Clear()

Returns

bool

true if there was an error to clear.

Remarks

MS-VBAL §6.1.3.2.1 lists what does this besides Err.Clear itself: a Resume statement, Exit Sub/Exit Function/Exit Property, and an On Error statement.

Raise(IVBRaisableError, long)

Records error as the session's current error, replacing any earlier one, and captures the call stack it was raised on.

void Raise(IVBRaisableError error, long lineNumber = 0)

Parameters

error IVBRaisableError

The error that was raised.

lineNumber long

The LineNumber to report for it: the line number in effect where it was raised, or 0 when no line-number label precedes that statement.

Remarks

Called for every run-time error the interpreter raises, whether or not anything goes on to handle it: Err is set by the error, not by the handling of it. The error's own number and description become Number and Description, overwriting whatever source had set them to — a new error is a new error.