1 | 'use strict';
|
2 | const debug = require('debug');
|
3 | const { autoExit } = require('./unref-timeout');
|
4 | const { red } = require('colors');
|
5 | const { FilterChain } = require('./error-processor');
|
6 | const filterChain = new FilterChain();
|
7 | const handler = function (err) {
|
8 |
|
9 | filterChain.process(err.message, err).then(processed => {
|
10 |
|
11 |
|
12 | if (debug.enabled('*') && err.stack) {
|
13 | console.error(err.stack);
|
14 | }
|
15 | else if (err.message) {
|
16 | console.error(red(err.message));
|
17 | }
|
18 | else {
|
19 | console.error(err);
|
20 | }
|
21 | process.exitCode = -1;
|
22 | autoExit(-1);
|
23 | });
|
24 | };
|
25 | module.exports = handler;
|