errorhandlr
Advanced tools
Comparing version 0.0.0 to 0.0.1
var printStackTrace = require('stacktrace-js') | ||
, util = require('util'); | ||
, util = require('util') | ||
, package = require('../package.json') | ||
, keen = require('keen.io'); | ||
var keen = keen.configure({ | ||
projectId: '526e157c05cd6660e8000000', | ||
writeKey: 'd4921aec11dc77b09c6523acf65e444462eee8078bd3ddce494fd8563a9b75ff49b4ee3845b920f71506fccdd5c00a22635d5e5fa8aa18c6fd55425b7da353db8fa39dcfcef933aaf3fc46b53caa85db2c3d4b2ba4af1efb68e0f80d6b251dba43f73405f5b21552bb95e2766eeba4da' | ||
}); | ||
function ErrorHandlr(options) { | ||
@@ -16,3 +23,3 @@ var self = this; | ||
var self = this | ||
, trace = err.stack || self._buildTrace(err); | ||
, trace; | ||
@@ -23,11 +30,15 @@ if (!(err instanceof Error)) { | ||
self.log(trace); | ||
self.log("\nhttp://google.com/foobar\n"); | ||
trace = err.stack || self._buildTraceString(err); | ||
if(die) { | ||
process.exit(1); | ||
} | ||
self._logError(err, function() { | ||
self.log(trace); | ||
if(die) { | ||
process.exit(1); | ||
} | ||
}); | ||
}; | ||
ErrorHandlr.prototype._buildTrace = function(err) { | ||
ErrorHandlr.prototype._buildTraceString = function(err) { | ||
var trace = printStackTrace({ e: err }); | ||
@@ -41,2 +52,34 @@ return err.name + ": " + err.message + "\n " + trace.join("\n "); | ||
ErrorHandlr.prototype._logError = function(err, cb) { | ||
var trace = printStackTrace({ e: err }) | ||
, os = require("os") | ||
, data = { | ||
name: err.name, | ||
message: err.message, | ||
trace: trace, | ||
env: { | ||
name: package.name, | ||
version: package.version, | ||
nodeVersion: process.version, | ||
hostName: os.hostname(), | ||
author: package.author, | ||
nodeDependencies: JSON.stringify(package.dependencies), | ||
nodeDevDependencies: JSON.stringify(package.devDependencies) | ||
} | ||
}; | ||
keen.addEvent("error-" + package.version, data, function(keenErr, keenRes) { | ||
if(keenErr) { | ||
console.error("\n****************************************"); | ||
console.error("An Unexpected Error Reporting Occured!"); | ||
console.error("Please report the following to Swift:\n"); | ||
console.error(keenErr + "\n"); | ||
console.error(JSON.stringify(data, undefined, 2) + "\n"); | ||
console.error("****************************************"); | ||
} | ||
cb(); | ||
}); | ||
}; | ||
module.exports = new ErrorHandlr(); |
{ | ||
"name": "errorhandlr", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Secret sauce.", | ||
"main": "lib/errorhandlr.js", | ||
"dependencies": { | ||
"stacktrace-js": "~0.5.0" | ||
"stacktrace-js": "~0.5.0", | ||
"keen.io": "0.0.3" | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"mocha": "~1.13.0", | ||
"expect.js": "~0.2.0", | ||
"sinon": "~1.7.3" | ||
}, | ||
"scripts": { | ||
@@ -11,0 +16,0 @@ "test": "make test" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5233
9
95
2
3
+ Addedkeen.io@0.0.3
+ Addedcookiejar@1.3.0(transitive)
+ Addedemitter-component@0.0.6(transitive)
+ Addedformidable@1.0.9(transitive)
+ Addedkeen.io@0.0.3(transitive)
+ Addedmethods@0.0.1(transitive)
+ Addedmime@1.2.5(transitive)
+ Addedqs@0.5.2(transitive)
+ Addedsuperagent@0.13.0(transitive)
+ Addedunderscore@1.4.4(transitive)