Skip to content

Commit ea33d83

Browse files
author
Pooya Parsa
committed
pretty-error integration
1 parent 5d06810 commit ea33d83

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

bin/nuxt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env node
22

33
const join = require('path').join
4+
require('../lib/common/errors')
45

56
const defaultCommand = 'dev'
67
const commands = new Set([
@@ -21,11 +22,4 @@ if (commands.has(cmd)) {
2122

2223
const bin = join(__dirname, 'nuxt-' + cmd)
2324

24-
// Console error unhandled promises
25-
process.on('unhandledRejection', function (err) {
26-
/* eslint-disable no-console */
27-
console.error(err)
28-
console.error('[nuxt] Unhandled promise rejection: ' + err)
29-
})
30-
3125
require(bin)

build/start.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const packageJSON = readJSONSync(resolve(rootDir, 'package.json'))
1414

1515
// Required and Excluded packages for start
1616
let requires = [
17-
'source-map-support'
17+
'source-map-support',
18+
'pretty-error'
1819
]
1920

2021
const excludes = [

lib/common/errors.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const PrettyError = require('pretty-error')
2+
3+
// Start default instance
4+
const pe = PrettyError.start()
5+
6+
// Configure prettyError instance
7+
pe.skipPackage('regenerator-runtime')
8+
pe.skipPackage('babel-runtime')
9+
pe.skipPackage('core-js')
10+
pe.skipNodeFiles()
11+
12+
// Console error unhandled promises
13+
process.on('unhandledRejection', function (err) {
14+
/* eslint-disable no-console */
15+
console.log(pe.render(err))
16+
})
17+
18+
module.exports = {
19+
pe
20+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
"minimist": "^1.2.0",
9898
"opencollective": "^1.0.3",
9999
"pify": "^3.0.0",
100+
"pretty-error": "^2.1.1",
100101
"progress-bar-webpack-plugin": "^1.10.0",
101102
"serialize-javascript": "^1.4.0",
102103
"serve-static": "^1.12.3",

start/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
},
4949
"dependencies": {
5050
"source-map-support": "^0.4.15",
51+
"pretty-error": "^2.1.1",
5152
"lodash": "^4.17.4",
5253
"hash-sum": "^1.0.2",
5354
"tappable": "^1.1.0",

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4944,7 +4944,7 @@ preserve@^0.2.0:
49444944
version "0.2.0"
49454945
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"
49464946

4947-
pretty-error@^2.0.2:
4947+
pretty-error@^2.0.2, pretty-error@^2.1.1:
49484948
version "2.1.1"
49494949
resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"
49504950
dependencies:

0 commit comments

Comments
 (0)