hook: Handle hook error and continue process

This commit is contained in:
Sébastien Chopin 2017-10-30 23:15:35 +01:00
parent ad59f788dc
commit daaa5bdd12

View File

@ -64,7 +64,13 @@ export default class Nuxt {
if (!this._hooks[name]) { if (!this._hooks[name]) {
return return
} }
debug(`Call ${name} hooks (${this._hooks[name].length})`)
try {
await sequence(this._hooks[name], (fn) => fn(...args)) await sequence(this._hooks[name], (fn) => fn(...args))
} catch (err) {
console.error(`> Error on hook "${name}":`) // eslint-disable-line no-console
console.error(err) // eslint-disable-line no-console
}
} }
listen(port = 3000, host = 'localhost') { listen(port = 3000, host = 'localhost') {