Skip to content

Commit 9ad95f5

Browse files
committed
[sentry][s]: all errors that is sent to 'handleError' function are reported to Sentry - refs #321
1 parent 03c5d93 commit 9ad95f5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/utils/error.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
1+
// Packages:
2+
const Raven = require('raven')
3+
4+
// Ours:
15
const error = require('./output/error')
6+
const {version} = require('../../package.json')
7+
const {installedWithNPM} = require('./tools')
8+
29

310
function handleError(err, {debug = false} = {}) {
11+
if (process.env.datahub !== 'dev') { // Send report to Sentry if not dev env
12+
// Setup Sentry:
13+
Raven.config('https://e29902aa81ed414d867f51bd0d1ab91a:[email protected]/305079', {
14+
release: version,
15+
extra: {
16+
firstArg: process.argv.slice(2, 3),
17+
rest: process.argv.slice(3, process.argv.length),
18+
nodejsOrBin: installedWithNPM ? process.version : 'bin'
19+
}
20+
})
21+
22+
// Capture errors:
23+
Raven.captureException(err, (sendErr, eventId) => {
24+
// Once report is sent exit with code 1:
25+
process.exit(1)
26+
})
27+
}
28+
429
// Coerce Strings to Error instances
530
if (typeof err === 'string') {
631
err = new Error(err)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
"mkdirp": "^0.5.1",
8686
"ora": "^1.3.0",
8787
"pkg": "4.2.5",
88+
"raven": "^2.4.2",
8889
"universal-analytics": "^0.4.16",
8990
"unzip": "^0.1.11",
9091
"update-notifier": "^2.3.0",

0 commit comments

Comments
 (0)