-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
User friendly server errors and automatic port switching (#164)
* more userfriendly server errors and automatically asign free port if port is busy * cleanup code a lil * fix typo * remove unused import * minor improvements * change double quotes into single quotes * lil cleanup & restructuring * bugfixes
- Loading branch information
1 parent
dc52638
commit 87350f4
Showing
7 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
let serverErrorList = { | ||
EACCES: "You don't have access to bind the server to port {port}.", | ||
EADDRINUSE: 'There is already a process listening on port {port}.' | ||
}; | ||
|
||
function serverErrors(err, port) { | ||
let desc = serverErrorList[err.code].replace(/{port}/g, port); | ||
if (!desc) { | ||
desc = `Error: ${ | ||
err.code | ||
} occurred while setting up server on port ${port}.`; | ||
} | ||
return desc; | ||
} | ||
|
||
module.exports.serverErrors = serverErrors; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters