-
Notifications
You must be signed in to change notification settings - Fork 2
/
SystemError.ts
40 lines (30 loc) · 1.31 KB
/
SystemError.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/// <reference path="../../use-strict" />
/// <reference path="ErrorClass" />
namespace Format.Errors {
Format.Errors.ErrorClass = Error;
/**
* Base system error class that allows for syntactic C#-like `Error` class extension.
*
* See: https://msdn.microsoft.com/library/system.systemexception.aspx
*/
export class SystemError extends ErrorClass {
/** The non-standard stack property of `Error` objects offer a trace of which functions were called, in what order, from which line and file, and with what arguments. */
public stack: string;
/** An inner error which the current error wraps. */
public innerError: Error;
/**
* Creates an abstract system error object derived from the built-in javascript `Error` type and decorates it with additional properties.
* @param message A human-readable description of the error.
* @param innerError An error to wrap while also preserving its stack trace.
*/
constructor(message?: string, innerError?: SystemError) {
super(message);
this.name = "SystemError";
this.message = message;
if (innerError) {
this.innerError = innerError;
this.stack = innerError.stack;
}
}
}
}