all files / montage/core/ exception.js

23.08% Statements 3/13
0% Branches 0/12
0% Functions 0/4
23.08% Lines 3/13
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98                                                                                                                                                                                              
var Montage = require("./core").Montage;
var logger = require("./logger").logger("exception");
 
/**
 * @module montage/core/exception
 * @requires montage/core/core
 * @requires montage/core/logger
*/
 
/**
 * @class Exception
 * @extends Montage
*/
var Exception = exports.Exception = Montage.specialize(/** @lends Exception# */ {
 
    /**
     * @type {Property}
     * @default {string} null
     */
    message: {
        value: null
    },
 
    /**
     * @type {Property}
     * @default {string} null
     */
    target: {
        value: null
    },
 
    /**
     * @type {Property}
     * @default {Function} null
     */
    method: {
        value: null
    },
 
    /**
     * @function
     * @param {string} message The message to be initialized.
     * @returns this.initWithMessageTargetAndMethod(message, null, null)
     */
    initWithMessage : {
        enumerable: true,
        value: function (message) {
            return this.initWithMessageTargetAndMethod(message, null, null);
        }
    },
 
    /**
     * @function
     * @param {string} message The message to be initialized.
     * @param {string} target The target to be initialized.
     * @returns this.initWithMessageTargetAndMethod(message, target, null)
     */
    initWithMessageAndTarget : {
        enumerable: true,
        value: function (message, target) {
            return this.initWithMessageTargetAndMethod(message, target, null);
        }
    },
 
    /**
     * @function
     * @param {string} message The message to be initialized.
     * @param {string} target The target to be initialized.
     * @param {Function} method The method to be initialized.
     * @returns itself
     */
    initWithMessageTargetAndMethod : {
        enumerable: true,
        value: function (message, target, method) {
            this.message = (typeof message !== 'undefined' ? message : null);
            Object.defineProperty(this, "message", {writable: false});
            this.target = (typeof target !== 'undefined' ? target : null);
            Object.defineProperty(this, "target", {writable: false});
            this.method = (typeof method !== 'undefined' ? method : null);
            Object.defineProperty(this, "method", {writable: false});
            return this;
        }
    },
 
    /**
     * @function
     * @returns The exception
     */
    toString: {
        enumerable: false,
        value: function () {
            return "Exception: " + (this.message !== null ? this.message + " " : null) + (this.target !== null ? this.target + " " : null) + (this.method !== null ? this.method + " " : null);
        }
    }
 
});