Class VBApplicationErrorInfo
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
CustomErrorCodeintThe 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.
LocationSourceLocationThe document location of what raised the error.
DescriptionstringThe error description. What
Err.Descriptionreports.VerbosestringA 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
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
HelpContext
The help context ID Err.Raise gave the error - the one it was given, or the one Err had and kept (MS-VBAL §6.1.3.2.1.2) -
or null for the one of its number's message, which an error the runtime raises has, and so does one an Error statement, an
automation object or a RegExp raises.
public int? HelpContext { get; init; }
Property Value
- int?
Source
The source Err.Raise gave the error - the one it was given, or the one Err had and kept (MS-VBAL §6.1.3.2.1.2) -
or null for the name of the project whose code runs (ProjectName),
which every other error has, one an Error statement raises among them (recorded in Excel: oracle\s61 H07-H10).
public string? Source { get; init; }
Property Value
Methods
ToDiagnosticCode()
The RD-VBAL §2.6.3 diagnostic code of this error, prefix and all.
public string ToDiagnosticCode()
Returns
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.