Skip to content

Commit

Permalink
Merge pull request #10 from Vijar/stack
Browse files Browse the repository at this point in the history
Better stack trace
  • Loading branch information
akshayp committed Sep 10, 2015
2 parents 9e30ddf + 67baa11 commit a10178b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
10 changes: 9 additions & 1 deletion HttpError.js
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -6,5 +6,6 @@
'use strict';

module.exports = {
http: require('./libs/fumble.http')
http: require('./libs/fumble.http'),
HttpError: require('./HttpError')
};
4 changes: 2 additions & 2 deletions 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 <mkouli@yahoo-inc.com>",
"main": "index.js",
"repository": {
Expand Down Expand Up @@ -29,14 +29,14 @@
"webpack": "^1.5"
},
"pre-commit": [
"lint",
"devtest"
],
"keywords": [
"yahoo",
"fetchr",
"error"
],

"licenses": [
{
"type": "BSD",
Expand Down

0 comments on commit a10178b

Please sign in to comment.