function createCustomErrorType ( name ) {

        function CustomError ( message ) {
            this.message = message;

            if ( Error.captureStackTrace ) {
                Error.captureStackTrace( this, this.constructor );
            } else {
                this.stack = ( new Error() ).stack;
            }
        }

        CustomError.prototype = new Error();
        CustomError.prototype.name = name;
        CustomError.prototype.constructor = CustomError;

        return CustomError;
    }
function createCustomErrorType ( name ) {

        function CustomError ( message ) {
            this.message = message;

            if ( Error.captureStackTrace ) {
                Error.captureStackTrace( this, this.constructor );
            } else {
                this.stack = ( new Error() ).stack;
            }
        }

        CustomError.prototype = new Error();
        CustomError.prototype.name = name;
        CustomError.prototype.constructor = CustomError;

        return CustomError;
    }
function createCustomErrorType ( name ) { function CustomError ( message ) { this . message = message ; if ( Error . captureStackTrace ) { Error . captureStackTrace ( this , this . constructor ) ; } else { this . stack = ( new Error ( ) ) . stack ; } } CustomError . prototype = new Error ( ) ; CustomError . prototype . name = name ; CustomError . prototype . constructor = CustomError ; return CustomError ; }
Creates and returns a custom error type.

See gist at https://gist.github.com/hashchange/4c1ce239570c77e698c1d2df09d0e540

@param   {string} name  of the error type
@returns {Error}
Creates and returns a custom error type .