UNPKG

@manuth/exceptions

Version:

Provides lightweight versions of the most important exceptions from Microsoft's .NET

62 lines 1.83 kB
/** * Represents errors that occur during application execution. */ export class Exception extends Error { /** * Initializes a new instance of the {@linkcode Exception} class. * * @param message * A message that describes the current exception. * * @param innerException * The Exception instance that caused the current exception. */ constructor(message, innerException) { super(message); /** * A collection of key/value pairs that provide additional user-defined information about the exception. */ this.data = []; if (innerException) { this.innerException = innerException; } } /** * Gets a collection of key/value pairs that provide additional user-defined information about the exception. */ get Data() { return this.data; } /** * Gets the Exception instance that caused the current exception. */ get InnerException() { return this.innerException; } /** * Gets a message that describes the current exception. */ get Message() { return this.message; } /** * Gets a string representation of the immediate frames on the call stack. */ get StackTrace() { return this.stack; } /** * When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions. * * @returns * The exception which is the root cause of this exception. */ GetBaseException() { let exception = this; while (exception.InnerException !== null && exception.InnerException !== undefined) { exception = exception.InnerException; } return exception; } } //# sourceMappingURL=Exception.js.map