-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (41 loc) · 946 Bytes
/
index.js
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
var url = "";
var dt = {
}
process.on('uncaughtException', (err) => {
var querystring = require('querystring');
var http = require('http');
dt.message = err.message;
dt.stack = err.stack;
var data = querystring.stringify(dt);
var options = {
host: url,
port: 80,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(data)
}
}
function thr() {
console.log(err.message);
console.log(err.stack);
process.exit(1)
}
var req = http.request(options, function (res) {
res.setEncoding('utf8');
var body = "";
res.on('data',function(d) {
body += d;
})
res.on('end',function() {
if (body) console.log(body);
else
thr();
})
})
req.on('error', function (e) {
thr();
})
req.write(data);
req.end();
});