all files / TypeScript.NET/source/System/ Exception.js

74.42% Statements 32/43
56% Branches 14/25
62.5% Functions 5/8
78.95% Lines 30/38
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                      57× 57× 57× 57× 57× 57× 57×   57× 51× 57× 57× 57× 57×     57×       57× 57×                    
/*!
 * @author electricessence / https://github.com/electricessence/
 * Licensing: MIT https://github.com/electricessence/TypeScript.NET/blob/master/LICENSE.md
 * Based upon: https://msdn.microsoft.com/en-us/library/System.Exception%28v=vs.110%29.aspx
 */
(function (factory) {
    Eif (typeof module === 'object' && typeof module.exports === 'object') {
        var v = factory(require, exports); Iif (v !== undefined) module.exports = v;
    }
    else if (typeof define === 'function' && define.amd) {
        define(["require", "exports"], factory);
    }
})(function (require, exports) {
    "use strict";
    var NAME = 'Exception';
    var Exception = (function () {
        function Exception(message, innerException, beforeSealing) {
            Iif (message === void 0) { message = null; }
            if (innerException === void 0) { innerException = null; }
            this.message = message;
            var _ = this;
            _.name = _.getName();
            _.data = {};
            Iif (innerException)
                _.data['innerException'] = innerException;
            if (beforeSealing)
                beforeSealing(_);
            try {
                var stack = (new Error()).stack;
                stack = stack && stack.replace(/^Error\n/, '').replace(/(.|\n)+\s+at new.+/, '') || '';
                this.stack = _.toStringWithoutBrackets() + stack;
            }
            catch (ex) { }
            Object.freeze(_);
        }
        Exception.prototype.getName = function () { return NAME; };
        Exception.prototype.toString = function () {
            return "[" + this.toStringWithoutBrackets() + "]";
        };
        Exception.prototype.toStringWithoutBrackets = function () {
            var _ = this, m = _.message;
            return _.name + (m ? (': ' + m) : '');
        };
        Exception.prototype.dispose = function () {
            var data = this.data;
            for (var k in data) {
                if (data.hasOwnProperty(k))
                    delete data[k];
            }
        };
        return Exception;
    }());
    exports.Exception = Exception;
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.default = Exception;
});
//# sourceMappingURL=Exception.js.map