From 67baa11be7dfb58c77046c4a8cb419f0e4e4bce3 Mon Sep 17 00:00:00 2001 From: Rajiv Tirumalareddy Date: Thu, 3 Sep 2015 13:36:31 -0700 Subject: [PATCH] Better stack trace --- HttpError.js | 10 +++++++++- index.js | 3 ++- package.json | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/HttpError.js b/HttpError.js index 96616b7..cf25fcd 100644 --- a/HttpError.js +++ b/HttpError.js @@ -22,12 +22,20 @@ function HttpError (status, message, options) { if (options.debug) { this.debug = options.debug; } + + // Stack Trace + if (Error.captureStackTrace) { + // if not IE + Error.captureStackTrace(this, this.constructor); + } else { + // in IE + this.stack = (new Error()).stack; + } } // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Example.3A_Custom_Error_Types HttpError.prototype = new Error(); HttpError.prototype.constructor = HttpError; - HttpError.prototype.name = 'HttpError'; module.exports = HttpError; diff --git a/index.js b/index.js index d54dac7..2d24da8 100644 --- a/index.js +++ b/index.js @@ -6,5 +6,6 @@ 'use strict'; module.exports = { - http: require('./libs/fumble.http') + http: require('./libs/fumble.http'), + HttpError: require('./HttpError') }; diff --git a/package.json b/package.json index 56067af..effce62 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "fumble", "description": "Simple error objects in node. Created specifically to be used with the fetchr library and based on hapi.js' Boom.", - "version": "0.1.0", + "version": "0.1.1", "author": "Mo Kouli ", "main": "index.js", "repository": { @@ -29,6 +29,7 @@ "webpack": "^1.5" }, "pre-commit": [ + "lint", "devtest" ], "keywords": [ @@ -36,7 +37,6 @@ "fetchr", "error" ], - "licenses": [ { "type": "BSD",