Show proper error for PORT in use (#864)

Signed-off-by: VighneshKSP <ksp.vighnesh@gmail.com>
This commit is contained in:
Vighnesh K S P
2018-10-18 11:03:22 +05:30
committed by typicode
parent 191539e8e5
commit 8471699c1d

View File

@ -132,6 +132,20 @@ module.exports = function(argv) {
// Display server informations
prettyPrint(argv, db.getState(), routes)
// Catch and handle any error occurring in the server process
process.on('uncaughtException', error => {
if (error.errno === 'EADDRINUSE')
console.log(
chalk.red(
`Cannot bind to the port ${
error.port
}. Specify some other port number either through --port argument or through the json-server.json configuration file`
)
)
else console.log('Some error occurred', error)
process.exit(1)
})
})
}