-
Notifications
You must be signed in to change notification settings - Fork 15
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
add log error for ping exception #61
Conversation
Thanks for your awesome pr to fix |
# Conflicts: # src/wechaty_puppet_service/puppet.py
I’m very happy to hear that, but I think there is still room for improvement here. ;) So I add try catch for ping call, and print some useful message for debug. Otherwise, due to the outer try catch, information will be lost, making it difficult to find the true problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your improvement looks so great, but we need your more unit test case.
if port is None: | ||
if ping(host) is False: | ||
try: | ||
if ping(host) is False: | ||
res = False | ||
except PermissionError as pe: | ||
log.error(pe) | ||
res = False | ||
except errors.PingError as e: | ||
log.error(f'got a ping error:\n{e}') | ||
res = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your improvement look so great to me. But I don't know in what situation the error will be raised. Can add some more detailed test case for PermissionError
and PingError
to help us understand the code ? If you can, it's great docs for developer to understand more about endpoint
. How do you think about it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for replay. :-)
There will be a PermissionError
, when I set end_point
to a service name and run script on a Linux machine without root. And without above codes, due to the outer try catch, I only got Wechaty - ERROR - The network is not good, the bot will try to restart after 60 seconds.
, which make people confusing. There need more message for figuring out the true problem, so I add try catch for ping call and print possible exception message.
By the way, I optimized the comment.
Yep, I think it's time to merge your code after you bump the version in |
Glad to hear this. I have submitted the |
Thank you very much for your contribution! You are welcome to join Wechaty Contributor Program1. Join Wechaty Organization
I have invited you to join our Wechaty GitHub Organization, please accept it by following the above message. (See also: wechaty/PMC#16) 2. Update Your Wechaty Contributor Profile
3. Join The Contributor Only WeChat RoomWe also have a WeChat room for contributors only which can discuss Wechaty at a deeper level, you are welcome to join and if you are interested. Please add @lijiarui wechat: ruirui_0914 and send her this pr link. She will invite you into Wechaty Contributor Room Cheers! |
|
#60