Skip to content

Remove stack trace for socket errors with mkdocs serve #596

Closed

Description

@samhatfield

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?

Activity

  1. samhatfield commented on Jun 5, 2015

    @samhatfield
    ContributorAuthor

    I meant port 8000, not 8080.

  2. d0ugal commented on Jun 5, 2015

    @d0ugal
    Contributor

    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.

  3. waylan commented on Jun 5, 2015

    @waylan
    Contributor

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

  4. d0ugal commented on Jun 5, 2015

    @d0ugal
    Contributor

    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!

  5. waylan commented on Jun 5, 2015

    @waylan
    Contributor

    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.

  6. d0ugal commented on Jun 5, 2015

    @d0ugal
    Contributor

    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.

  7. samhatfield commented on Jun 5, 2015

    @samhatfield
    ContributorAuthor

    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.

  8. waylan commented on Jun 5, 2015

    @waylan
    Contributor

    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.

  9. samhatfield commented on Jun 5, 2015

    @samhatfield
    ContributorAuthor

    Sure thing, #600 submitted.

  10. d0ugal commented on Jun 6, 2015

    @d0ugal
    Contributor

    Merged. Thanks!

  11. added this to the 0.14.0 milestone on Jun 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions