lib/index.js
function erroz(error) {

    var errorFn = function (data) {

        //apply all attributes on the instance
        for (var errKey in errorFn.prototype) {
            if (errorFn.prototype.hasOwnProperty(errKey)) {
                this[errKey] = errorFn.prototype[errKey];
            }
        }

        //overwrite message if invoked with string
        if (typeof data === "string") {
            this.message = data;
            data = {};
        }

        this.data = data || {};

        this.message = this.message || erroz.options.renderMessage(error.template || "", this.data);

        errorFn.super_.call(this, this.constructor);
    };

    util.inherits(errorFn, AbstractError);

    //add static error properties (name, status, etc)
    for (var errKey in error) {
        if (error.hasOwnProperty(errKey)) {
            errorFn.prototype[errKey] = error[errKey];
        }
    }

    /**
     * return an object containing only JSend attributes
     * @returns {{status: *, code: *, message: *, data: (*|string|Object[]|Object|String)}}
     */
    errorFn.prototype.toJSend = function () {
        var data = this.data;

        if (erroz.options.includeStack && this.stack) {
            data.stack = this.stack;
        }

        if (!this.status) {
            this.status = deriveStatusFromStatusCode(this.statusCode);
        }

        return {
            status: this.status,
            code: this.code,
            message: this.message,
            data: data
        };
    };

    return errorFn;
}
function erroz(error) {

    var errorFn = function (data) {

        //apply all attributes on the instance
        for (var errKey in errorFn.prototype) {
            if (errorFn.prototype.hasOwnProperty(errKey)) {
                this[errKey] = errorFn.prototype[errKey];
            }
        }

        //overwrite message if invoked with string
        if (typeof data === "string") {
            this.message = data;
            data = {};
        }

        this.data = data || {};

        this.message = this.message || erroz.options.renderMessage(error.template || "", this.data);

        errorFn.super_.call(this, this.constructor);
    };

    util.inherits(errorFn, AbstractError);

    //add static error properties (name, status, etc)
    for (var errKey in error) {
        if (error.hasOwnProperty(errKey)) {
            errorFn.prototype[errKey] = error[errKey];
        }
    }

    /**
     * return an object containing only JSend attributes
     * @returns {{status: *, code: *, message: *, data: (*|string|Object[]|Object|String)}}
     */
    errorFn.prototype.toJSend = function () {
        var data = this.data;

        if (erroz.options.includeStack && this.stack) {
            data.stack = this.stack;
        }

        if (!this.status) {
            this.status = deriveStatusFromStatusCode(this.statusCode);
        }

        return {
            status: this.status,
            code: this.code,
            message: this.message,
            data: data
        };
    };

    return errorFn;
}
function erroz ( error ) { var errorFn = function ( data ) { //apply all attributes on the instance for ( var errKey in errorFn . prototype ) { if ( errorFn . prototype . hasOwnProperty ( errKey ) ) { this [ errKey ] = errorFn . prototype [ errKey ] ; } } //overwrite message if invoked with string if ( typeof data === "string" ) { this . message = data ; data = { } ; } this . data = data || { } ; this . message = this . message || erroz . options . renderMessage ( error . template || "" , this . data ) ; errorFn . super_ . call ( this , this . constructor ) ; } ; util . inherits ( errorFn , AbstractError ) ; //add static error properties (name, status, etc) for ( var errKey in error ) { if ( error . hasOwnProperty ( errKey ) ) { errorFn . prototype [ errKey ] = error [ errKey ] ; } } /**
     * return an object containing only JSend attributes
     * @returns {{status: *, code: *, message: *, data: (*|string|Object[]|Object|String)}}
     */ errorFn . prototype . toJSend = function ( ) { var data = this . data ; if ( erroz . options . includeStack && this . stack ) { data . stack = this . stack ; } if ( ! this . status ) { this . status = deriveStatusFromStatusCode ( this . statusCode ) ; } return { status : this . status , code : this . code , message : this . message , data : data } ; } ; return errorFn ; }
generate Error-classes based on ErrozError

@param error
@returns {Function}
generate Error - classes based on ErrozError