Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to catch errors? #93

Closed
nfriend opened this issue Mar 28, 2017 · 3 comments
Closed

Is there a way to catch errors? #93

nfriend opened this issue Mar 28, 2017 · 3 comments

Comments

@nfriend
Copy link

nfriend commented Mar 28, 2017

If I start a second instance of a node-livereload server, I get the follow message and a stack trace, which is to be expected:

Error: listen EADDRINUSE :::35729
    ... stacktrace here ...

However, I can't figure out a way to catch and prevent this message from being printed in the console. I've tried try/catch, but the error happens asynchronously (and probably in another process?).

My use-case for this: I'd like to be able to catch the error and print a friendlier error message, like "Unable to start the LiveReload server! This is most likely because you have another instance of the LiveReload server running on this port."

@napcs
Copy link
Owner

napcs commented Mar 29, 2017

@nfriend How are you invoking the server? Through the CLI or are you using the API directly?

@nfriend
Copy link
Author

nfriend commented Mar 29, 2017

I'm using the API directly:

const livereload = require('livereload');

const server = livereload.createServer();
server.watch('path/to/watch');

@napcs
Copy link
Owner

napcs commented Feb 24, 2018

@nfriend 0.7.0 is released. It now supports an error event you can watch. The examples/ folder has an example of this.

@napcs napcs closed this as completed Feb 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants