35 lines
699 B
JavaScript
35 lines
699 B
JavaScript
import chalk from 'chalk'
|
|
import Console from '@bmp/console'
|
|
import hs from 'highlight-stack'
|
|
|
|
const highlightStack = hs.default
|
|
|
|
// make error output stack pretty
|
|
process.on('uncaughtException', (err) => {
|
|
console.error(chalk.red('UNCAUGHT EXCEPTION'))
|
|
|
|
if (err.stack) {
|
|
console.error(highlightStack(err.stack))
|
|
} else {
|
|
console.error(err)
|
|
}
|
|
|
|
process.exit(1)
|
|
})
|
|
|
|
process.on('unhandledRejection', (err) => {
|
|
console.error(chalk.red('UNHANDLED REJECTION'))
|
|
|
|
if (err.stack) {
|
|
console.error(highlightStack(err.stack))
|
|
} else {
|
|
console.error(err)
|
|
}
|
|
|
|
process.exit(1)
|
|
})
|
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
Console({ log: true, error: true, dir: true })
|
|
}
|