-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathErrorReport.js
More file actions
62 lines (56 loc) · 1.44 KB
/
Copy pathErrorReport.js
File metadata and controls
62 lines (56 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module.exports = {
/**
* Report an error to rollbar
* @param {Error} error
* @param {Object} config
* @param args
* @return {Promise<number>}
*/
async report(error, config, args) {
const os = require('os');
const got = require('got');
const pkg = require('../package.json');
const stack = error.stack.split('\n').map(x => x.trim());
stack.shift();
const frames = [];
stack.forEach((line) => {
const match = new RegExp(/at (.*) \((.*):(\d*?):(\d*?)\)/gi).exec(line);
frames.push({
filename: match[2],
lineno: match[3],
colno: match[4],
method: match[1],
});
});
const platform = os.platform();
const arch = os.arch();
const hostname = os.hostname();
const cliVersion = pkg.version;
const { body } = await got('https://api.rollbar.com/api/1/item/', {
body: {
access_token: 'f7bc938132944f90bf6c12c9088fbe0b',
data: {
environment: 'development',
body: {
trace: {
frames,
exception: {
class: error.name,
message: error.message,
},
},
code_version: cliVersion,
platform,
language: 'javascript',
arch,
hostname,
config,
args,
},
},
},
json: true,
});
return body.result.uuid;
},
};