System.Exception

Type
Location: igium / Igium.Web / System / System.Exception
Examples: Igium.Web Examples

System.Exception Type Constructors

Constructor Description
new System.Exception(errspace: {code: String, name: String}, info: {code: String, name: String, message: String}, innerException: Exception) Creates a System.Exception instance
- errspace.code: String The code of the error space of this exception, as described in the Error Space Registry
- errspace.name: String The name of the error space of this exception, as described in the Error Space Registry
- info.code: String Error code. By convention consists of 4 digits, padded with zeros, e.g. "0001". Must be the same for all instances of an exception type.
- info.name: String Error name. A short description of the error, e.g. "Invalid operation" or "Cannot instantiate an enumeration type". Must be the same for all instances of an exception type.
- info.message: String Error message. An instance-specific error text.
- innerException: Exception When an exception X is thrown as a direct result of a previous exception Y, the InnerException property of X should contain a reference to Y. --https://msdn.microsoft.com/en-us/library/system.exception.innerexception(v=vs.110).aspx

System.Exception Type Fields

Field Description
errspace: {code: String, name: String} The code and the name of the error space of this exception, as described in the Error Space Registry
code: String Error code. By convention consists of 4 digits, padded with zeros, e.g. "0001". Must be the same for all instances of an exception type.
name: String Error name. A short description of the error, e.g. "Invalid operation" or "Cannot instantiate an enumeration type". Must be the same for all instances of an exception type.
message: String Error message. An instance-specific error text.
id: String Error id in the form EIG<errspace code><exception code>, e.g. EIG00010013.
text: String Error full text in the form <errspace name> EIG<errspace code><exception code>: <exception name>.[ <exception message>.], e.g. EIG00010013.

System.Exception Type Methods

Method Description
toString(): String returns the value of the text field.
equals(ex: System.Exception): Boolean Compares the fields of two exceptions.

System.Exception Type Static Methods

Method Description
[Static], System.Exception.registerErrspace(errspaceDef: {code: String, name: String}): void Validates the errspaceDef objects and adds it to the System.Exception.errspace dictionary.

System.Exception Type Static Fields

Field Description
[Static], System.Exception.errspace: {<code: String>: errspaceDef: {code: String, name: String}} A dictionary of all registered error spaces. The recommended way to reference an error space when defining a new exception looks like this System.Exception.errspace.EIG0001.

Remarks

A base type for all exceptions. Not intended for direct use!

It is recommended to apply the [InstanceFrozen] attribute to all types that derive from System.Exception.

Examples

Registering a New Error Space

1
System.Exception.registerErrspace({code: "EIG0000", name: "SystemError"});

Defining a New Exception

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace("System",
 
    [InstanceFrozen]
    type // InvalidArgumentException
    (
        inherit(System.Exception),
 
        function InvalidArgumentException(argumentName, message, innerException)
        {
            InvalidArgumentException.base.call(this, System.Exception.errspace.EIG0000,
            {
                code: "0004",
                name: "Invalid argument",
                message: message,
            }, innerException);
 
            this.argumentName = argumentName;
        },
        {
            argumentName: null,
        }
    )
)

Unit tests: n/a