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

Remove stack trace for socket errors with mkdocs serve #596

Closed
samhatfield opened this Issue Jun 5, 2015 · 10 comments

Comments

Projects
None yet
3 participants
@samhatfield
Contributor

samhatfield commented Jun 5, 2015

I often forget I already have a server running on localhost:8080, and whenever I run mkdocs serve I get a huge stack trace with a '[Errno 98] Address already in use' at the end. I think we should just catch socket errors and spit out the error message, like for ConfigurationError. Here's what you could do. Should we catch all socket errors though? Or just keep 98 and re-throw the rest?

@samhatfield

This comment has been minimized.

Contributor

samhatfield commented Jun 5, 2015

I meant port 8000, not 8080.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Jun 5, 2015

Ha, I often do this too. Or i have another tool running on 8000 and forget.

I think we should catch it and just output an error message.

@waylan

This comment has been minimized.

Member

waylan commented Jun 5, 2015

@samhatfield why not create a pull request with your proposed change? That seems like the most sensible fix to me.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Jun 5, 2015

I think @samhatfield is learning GitHub, but yeah, go ahead and open a pull request :) It is best to propose changes with pull requests so we can easily review/merge.

Another addition to the release notes would be great too!

@waylan

This comment has been minimized.

Member

waylan commented Jun 5, 2015

Sorry if my tone was off. I noticed that @samhatfield had asked for feedback on his proposed change. However he hadn't received any feedback specifically about that (at least by my reading) -- only that the general request was reasonable. I was trying to tell him that I thought his proposed change looked good and he should submit a PR. Of course, final approval comes from @d0ugal so I did not give any definitive statements regarding whether such a PR would be accepted.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Jun 5, 2015

Not at all :) it was useful, I actually missed the link to the commit when I read it too quickly. So glad you mentioned it, I thought it was just a very reasonable suggestion.

@samhatfield

This comment has been minimized.

Contributor

samhatfield commented Jun 5, 2015

I was just about to submit a PR earlier, but then I saw that socket.error is a deprecated alias of OSError as of Python 3.3. OSError seems too broad to catch, and I couldn't find any appropriate subclasses. If you guys think it's fine as it is though, I'll submit a PR.

@waylan

This comment has been minimized.

Member

waylan commented Jun 5, 2015

Well, for Python < 3.3 we would still need to catch the socket.error so it doesn't cause any harm to leave it in. It appears that up through 3.6 socket.error will still be in the code base--it just inherits from a different parent class. So I would say leave it as-is.

Although, an argument could be made to catch all errors on the command line (except when in debug mode) and only output the message. However, I expect that would be a more complex issue that should be implemented across the entire CLI.

@samhatfield

This comment has been minimized.

Contributor

samhatfield commented Jun 5, 2015

Sure thing, #600 submitted.

@d0ugal

This comment has been minimized.

Member

d0ugal commented Jun 6, 2015

Merged. Thanks!

@d0ugal d0ugal closed this Jun 6, 2015

@d0ugal d0ugal added the Cleanup label Jun 6, 2015

@d0ugal d0ugal added this to the 0.14.0 milestone Jun 6, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment