We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 191539e commit 8471699Copy full SHA for 8471699
src/cli/run.js
@@ -132,6 +132,20 @@ module.exports = function(argv) {
132
133
// Display server informations
134
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
+ })
149
})
150
}
151
0 commit comments