Skip to content

Commit da41831

Browse files
author
Guillaume Chau
committed
feat: config.onError
1 parent ad49f88 commit da41831

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

docs/guide/configuration.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,26 @@ module.exports = {
2424
nodeExternalsWhitelist: [/\.css$/, /\?vue&type=style/],
2525
// Static files Cache-Control maxAge value
2626
staticCacheTtl: 1000 * 60 * 60 * 24 * 30,
27+
// Directives fallback
28+
directives: {
29+
// See 'Directive' chapter
30+
},
31+
lruCacheOptions: {
32+
// See https://ssr.vuejs.org/guide/caching.html
33+
},
2734
// Function to connect custom middlewares
2835
extendServer: app => {
2936
const cookieParser = require('cookie-parser')
3037
app.use(cookieParser())
3138
},
39+
onError: error => {
40+
// Send to error monitoring service
41+
},
3242
// Paths
3343
distPath: path.resolve(__dirname, './dist'),
3444
error500Html: null,
3545
templatePath: path.resolve(__dirname, './dist/index.html'),
3646
serviceWorkerPath: path.resolve(__dirname, './dist/service-worker.js'),
37-
// Directives fallback
38-
directives: {
39-
// See 'Directive' chapter
40-
}
41-
lruCacheOptions: {
42-
// See https://ssr.vuejs.org/guide/caching.html
43-
},
4447
}
4548
}
4649
}

lib/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ module.exports = (app, options) => {
126126
? errorHtml = errorHtml.replace('<!--server-error-msg-->', errorMessage)
127127
: errorHtml += errorMessage
128128
}
129+
130+
if (config.onError) {
131+
config.onError(err)
132+
}
129133
}
130134

131135
res.status(500).send(errorHtml)

lib/config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ module.exports = {
1010
nodeExternalsWhitelist: [/\.css$/, /\?vue&type=style/],
1111
extendServer: null,
1212
staticCacheTtl: 1000 * 60 * 60 * 24 * 30,
13+
directives: {},
14+
lruCacheOptions: {},
15+
onError: null,
1316
// Paths
1417
distPath: null,
1518
error500Html: null,
1619
templatePath: null,
1720
serviceWorkerPath: null,
18-
directives: {},
19-
lruCacheOptions: {},
2021
}

0 commit comments

Comments
 (0)