Skip to content

Commit 675a3cb

Browse files
committed
Merge branch 'master' of https://github.com/typicode/json-server
2 parents 6295994 + 8471699 commit 675a3cb

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/cli/run.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,20 @@ module.exports = function(argv) {
132132

133133
// Display server informations
134134
prettyPrint(argv, db.getState(), routes)
135+
136+
// Catch and handle any error occurring in the server process
137+
process.on('uncaughtException', error => {
138+
if (error.errno === 'EADDRINUSE')
139+
console.log(
140+
chalk.red(
141+
`Cannot bind to the port ${
142+
error.port
143+
}. Specify some other port number either through --port argument or through the json-server.json configuration file`
144+
)
145+
)
146+
else console.log('Some error occurred', error)
147+
process.exit(1)
148+
})
135149
})
136150
}
137151

0 commit comments

Comments
 (0)