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

add log error for ping exception #61

Merged
merged 5 commits into from
Aug 6, 2021
Merged

Conversation

yangruihan
Copy link
Contributor

#60

@yangruihan yangruihan requested a review from a team as a code owner August 3, 2021 15:50
@CLAassistant
Copy link

CLAassistant commented Aug 3, 2021

CLA assistant check
All committers have signed the CLA.

@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Aug 4, 2021

Thanks for your awesome pr to fix ping error. But this problem has been fixed in another pr: #59 . If you have willing, you can try to improve the doc of python-wechaty.
In short, Thanks for your working.

@yangruihan
Copy link
Contributor Author

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.

Copy link
Collaborator

@wj-Mcat wj-Mcat left a 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.

Comment on lines 60 to 69
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
Copy link
Collaborator

@wj-Mcat wj-Mcat Aug 5, 2021

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 ?

Copy link
Contributor Author

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.

@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Aug 6, 2021

Yep, I think it's time to merge your code after you bump the version in VERSION file to trigger CD stage. So waiting for your new commit.

@yangruihan
Copy link
Contributor Author

Glad to hear this.

I have submitted the VERSION file. :-)

@wj-Mcat wj-Mcat merged commit 3b76f5c into wechaty:master Aug 6, 2021
@wj-Mcat
Copy link
Collaborator

wj-Mcat commented Aug 6, 2021

Thank you very much for your contribution!

You are welcome to join Wechaty Contributor Program

1. Join Wechaty Organization

You've invited AIAmber to Wechaty! They'll be receiving an email shortly. They can also visit https://github.com/wechaty to accept the invitation.

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

  1. Please open Contributor Hall of Fame and add yourself to the end of the list, so that other contributors will know you better!
  2. Please add yourself to our Website Contributors by creating a PR and refer to this PR link as well.

3. Join The Contributor Only WeChat Room

We 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!

@huan
Copy link
Member

huan commented Aug 6, 2021

You've invited Ryan to Wechaty! They'll be receiving an email shortly. They can also visit https://github.com/wechaty to accept the invitation.

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

Successfully merging this pull request may close these issues.

4 participants