Skip to content

get more information about failed connect() to the caller #113

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

Closed
vladak opened this issue Aug 16, 2022 · 0 comments
Closed

get more information about failed connect() to the caller #113

vladak opened this issue Aug 16, 2022 · 0 comments

Comments

@vladak
Copy link
Contributor

vladak commented Aug 16, 2022

When connect() fails due to repeated failures, it throws RuntimeError:

try:
sock.connect((connect_host, port))
except MemoryError:
sock.close()
sock = None
except OSError:
sock.close()
sock = None
if sock is None:
raise RuntimeError("Repeated socket failures")

This is not very useful for the caller. Some suggestions:

  • rethrow the last exception
  • wrap the exceptions raised by connect() into RuntimeError exception (or maybe used dedicated exception)
  • add some info about the problem to the RuntimeError text (including how many times it tried)
vladak added a commit to vladak/Adafruit_CircuitPython_MiniMQTT that referenced this issue Aug 18, 2022
rtwfroody pushed a commit to rtwfroody/Adafruit_CircuitPython_MiniMQTT that referenced this issue Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant