Skip to content

Commit

Permalink
Show proper error for PORT in use (#864)
Browse files Browse the repository at this point in the history
Signed-off-by: VighneshKSP <ksp.vighnesh@gmail.com>
  • Loading branch information
Vighnesh K S P authored and typicode committed Oct 18, 2018
1 parent 191539e commit 8471699
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/cli/run.js
Expand Up @@ -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)
})
})
}

Expand Down

0 comments on commit 8471699

Please sign in to comment.