fix[Mock]: add error handling
This commit is contained in:
parent
74da10ca29
commit
16d39eb015
|
@ -48,6 +48,7 @@ module.exports = app => {
|
||||||
ignoreInitial: true
|
ignoreInitial: true
|
||||||
}).on('all', (event, path) => {
|
}).on('all', (event, path) => {
|
||||||
if (event === 'change' || event === 'add') {
|
if (event === 'change' || event === 'add') {
|
||||||
|
try {
|
||||||
// remove mock routes stack
|
// remove mock routes stack
|
||||||
app._router.stack.splice(mockStartIndex, mockRoutesLength)
|
app._router.stack.splice(mockStartIndex, mockRoutesLength)
|
||||||
|
|
||||||
|
@ -59,6 +60,9 @@ module.exports = app => {
|
||||||
mockStartIndex = mockRoutes.mockStartIndex
|
mockStartIndex = mockRoutes.mockStartIndex
|
||||||
|
|
||||||
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
console.log(chalk.magentaBright(`\n > Mock Server hot reload success! changed ${path}`))
|
||||||
|
} catch (error) {
|
||||||
|
console.log(chalk.redBright(error))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue