aboutsummaryrefslogtreecommitdiff
path: root/_mint/internal/_exceptionManager.js
blob: 0f9cf7c4f7d07c487e4c3ac329589c3274352b90 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module.exports = class MintExceptionManagerError extends Error {
    constructor(name, message, stack) {
        super(message);
        if (name.startsWith("mint.lang")) {
            let type = name.substr(10);
            if (
                   type !== "CodeEvalException"
                && type !== "OutOfBoundsException"
                && type !== "VariableNotFoundException"
                && type !== "InternalSyntaxException"
                && type !== "IncompatibleTypesException"
                && type !== "URIFunctionsException"
                && type !== "CombinedFailuresException"
                && type !== "InternalKernelException"
                && type !== "InternalException"
            ) {
                this.name = "MintLangInternalException";
            }
        } else if (name.startsWith("js.core.")) {
            let type = name.substr(8);
            switch (type) {
                case "EvalError":
                    this.name = "MintLangCodeEvalException";
                    break;
                case "RangeError":
                    this.name = "MintLangOutOfBoundsException";
                    break;
                case "ReferenceError":
                    this.name = "MintLangVariableNotFoundException";
                    break;
                case "SyntaxError":
                    this.name = "MintLangInternalSyntaxException";
                    break;
                case "TypeError":
                    this.name = "MintLangIncompatibleTypesException";
                    break;
                case "URIError":
                    this.name = "MintLangURIFunctionsException";
                    break;
                case "AggregateError":
                    this.name = "MintLangCombinedFailuresException";
                    break;
                case "InternalError":
                    this.name = "MintLangInternalKernelException";
                    break;
                default:
                    this.name = "MintLangInternalException";
                    break;
            }
        } else {
            this.name = "MintLangInternalException";
        }
        if (typeof stack !== "undefined") {
            this.stack = stack;
        }
    }
}