1 | "use strict"
|
2 |
|
3 | var PrettyError = require('pretty-error');
|
4 | var pe = new PrettyError();
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function errorHandler(error) {
|
12 |
|
13 | var prettyError = pe.render(new Error(error));
|
14 |
|
15 | console.error('');
|
16 | console.error(prettyError);
|
17 |
|
18 | process.exit(1);
|
19 | }
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function setPrettyErrrorTheme() {
|
25 | pe.appendStyle({
|
26 | 'pretty-error > header > title > kind': {
|
27 | display: 'none'
|
28 | },
|
29 |
|
30 |
|
31 | 'pretty-error > header > colon': {
|
32 | display: 'none'
|
33 | },
|
34 |
|
35 |
|
36 | 'pretty-error > header > message': {
|
37 | color: 'bright-white',
|
38 |
|
39 | background: 'red',
|
40 | padding: '0 1'
|
41 | },
|
42 |
|
43 |
|
44 | 'pretty-error > trace > item': {
|
45 | marginLeft: 2,
|
46 | marginBottom: 0,
|
47 | bullet: '"<grey>· </grey>"'
|
48 | },
|
49 |
|
50 | 'pretty-error > trace > item > header > pointer > file': {
|
51 | color: 'yellow'
|
52 | },
|
53 |
|
54 | 'pretty-error > trace > item > header > pointer > colon': {
|
55 | color: 'yellow'
|
56 | },
|
57 |
|
58 | 'pretty-error > trace > item > header > pointer > line': {
|
59 | color: 'bright-cyan'
|
60 | },
|
61 |
|
62 | 'pretty-error > trace > item > header > what': {
|
63 | color: 'bright-white'
|
64 | },
|
65 |
|
66 | 'pretty-error > trace > item > footer > addr': {
|
67 |
|
68 | marginLeft: 4
|
69 | }
|
70 | });
|
71 | }
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | function setPrettyErrorConfig() {
|
77 | pe.skipNodeFiles();
|
78 | }
|
79 |
|
80 | setPrettyErrrorTheme();
|
81 | setPrettyErrorConfig();
|
82 |
|
83 | module.exports = errorHandler |
\ | No newline at end of file |