Table of Contents

Class VBApplicationErrorInfo

Namespace
RDCore.SDK.Model.Errors
Assembly
RDCore.SDK.dll

Encapsulates the serializable error data for an application error: a run-time error workspace source raised for itself, with an Error statement (MS-VBAL §5.4.4.3) or with Err.Raise (§6.1.3.2.1.2).

public record VBApplicationErrorInfo : VBErrorInfo, IEquatable<VBErrorInfo>, IVBRaisableError, IEquatable<VBApplicationErrorInfo>
Inheritance
VBApplicationErrorInfo
Implements
Inherited Members

Remarks

🧩 Errors should be used to generate error diagnostics.

MS-VBAL does not distinguish this from an error the runtime semantics report — both are run-time errors, both interrupt the activation, both reach Err, both may be caught. RD-VBAL §2.6.3 does, in one respect: the diagnostic families differ, so the editor can say whether a workspace raised its own error or tripped over one. The distinction is in who raised it and nothing else — Err.Raise 11 is an application error, not a division-by-zero, even though 11 is a code MS-VBA defines.

Constructors

VBApplicationErrorInfo(int, SourceLocation, string, string)

Encapsulates the serializable error data for an application error: a run-time error workspace source raised for itself, with an Error statement (MS-VBAL §5.4.4.3) or with Err.Raise (§6.1.3.2.1.2).

public VBApplicationErrorInfo(int CustomErrorCode, SourceLocation Location, string Description, string Verbose)

Parameters

CustomErrorCode int

The custom workspace application error code. MS-VBAL §6.1.3.2.1.2 reserves 0-512 for system errors and 513-65535 for user-defined ones.

Location SourceLocation

The document location of what raised the error.

Description string

The error description. What Err.Description reports.

Verbose string

A detailed description of the error.

Remarks

🧩 Errors should be used to generate error diagnostics.

MS-VBAL does not distinguish this from an error the runtime semantics report — both are run-time errors, both interrupt the activation, both reach Err, both may be caught. RD-VBAL §2.6.3 does, in one respect: the diagnostic families differ, so the editor can say whether a workspace raised its own error or tripped over one. The distinction is in who raised it and nothing else — Err.Raise 11 is an application error, not a division-by-zero, even though 11 is a code MS-VBA defines.

Properties

AsErrorInfo

This error as the diagnostic source metadata it is.

public VBErrorInfo AsErrorInfo { get; }

Property Value

VBErrorInfo

Remarks

Every raisable error is a VBErrorInfo — that is the constraint C# has no way to state on an interface, so it is stated here instead, and implemented as this. It is what lets a carrier hold the interface, keeping the diagnostic family with the error, and still hand the error to the diagnostics pipeline, which is generic over the record rather than over this.

CustomErrorCode

The custom workspace application error code. MS-VBAL §6.1.3.2.1.2 reserves 0-512 for system errors and 513-65535 for user-defined ones.

public int CustomErrorCode { get; init; }

Property Value

int

Methods

Raised(int, SourceLocation, string, string?)

Creates the error an Error statement or an Err.Raise generates.

public static VBApplicationErrorInfo Raised(int errorNumber, SourceLocation location, string verbose, string? description = null)

Parameters

errorNumber int

The error code the workspace raised.

location SourceLocation

The document location of the Error statement or Err.Raise invocation.

verbose string

A detailed message that is optionally appended, depending on the current server trace configuration.

description string

The description the raiser supplied, or null to derive one from errorNumber.

Returns

VBApplicationErrorInfo

Remarks

The description is the raiser's own when it supplied one. Unspecified, MS-VBAL §6.1.3.2.1.2 says to use "the String that would be returned by the Error function" for errorNumber, or "Application-defined or object-defined error" when it corresponds to no VBA error — which is what GetErrorString(VBRuntimeErrorId) falls back to.

ToDiagnosticCode()

The RD-VBAL §2.6.3 diagnostic code of this error, prefix and all.

public string ToDiagnosticCode()

Returns

string

Remarks

👉 A member rather than an extension, deliberately. An extension binds to the static type of what it is called on, so an application error held in a variable declared as anything more general would silently report the wrong family — which is exactly how an error travels through the interpreter.