forked from browserify/wzrd.in
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stringify-error.js
56 lines (46 loc) · 1.25 KB
/
stringify-error.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
50
51
52
53
54
55
56
var util = require('util');
var log = require('minilog')('browserify-cdn');
var stringify = module.exports = function stringifyError(err) {
var internal = [], external = [];
if (err.stack) {
err.stack.split('\n').forEach(function (l) {
internal.push(l);
});
}
else {
internal.push(err.message || 'unspecified error');
}
if (err.message) {
external.push('Error: "' + err.message + '"');
}
else {
external.push('Error: An unspecified error has occurred.');
external.push('(Yes, I know. How helpful.)');
}
internal.push('');
external.push('');
Object.keys(err).forEach(function (k) {
var s = k + ': ' + util.format(err[k]);
internal.push(s);
external.push(s);
});
internal.forEach(function (l) {
log.error(l);
});
return external.join('\n');
};
stringify.hello = '---FLAGRANT SYSTEM ERROR---\n'
stringify.goodbye = [
'',
'This is probably an issue with the package, and not browserify-cdn itself.',
'If you feel differently, feel free to file a bug report at:',
'',
' https://github.com/jesusabdullah/browserify-cdn/issues',
'',
'Include the ENTIRETY of the contents of this message, and he can',
'try to help you out.',
'',
'Have a nice day!',
'',
''
].join('\n');