Skip to content

Commit

Permalink
Merge pull request #20 from wearrrrr/main
Browse files Browse the repository at this point in the history
Add nicer looking error handling for dynamic's index.js
  • Loading branch information
Avad3 authored Aug 13, 2023
2 parents 613d463 + 4fee04b commit cbe5699
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ fastify.register(fastifyStatic, {

const URL = `http://localhost:${port}/`;
fastify.listen({ port }, async (err) => {
if (err && err.code !== "EADDRINUSE") {
console.log(chalk.red.bold(`[Dynamic ${_v}] `) + "Port is already in use! Please close any apps using port " + chalk.bold.underline.red(port) + " and try again.");
process.exit(1);
} else if (err) {
console.log(chalk.bold.red(`[Dynamic ${_v}] `) + "An error occurred while starting the server! \n" + err);
process.exit(1);
}
console.log(chalk.bold('Thanks for using Dynamic!'), chalk.red(`Please notice that ${chalk.red.bold('dynamic is currently in public BETA')}. please report all issues to the GitHub page. `))
console.log(chalk.green.bold(`Dynamic ${_v} `) + "live at port " + chalk.bold.green(port));
try {
await open(URL);
} catch (ERR) {
console.error(ERR);
}
if (err) throw new Error(err);
});

0 comments on commit cbe5699

Please sign in to comment.