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

fix: catch network exceptions and keep the loop going #22

Merged
merged 2 commits into from
Aug 22, 2024

Conversation

kyteinsky
Copy link
Contributor

No description provided.

@bigcat88
Copy link
Member

lib/main.py Outdated
Comment on lines 78 to 94
except Exception as e: # noqa
print(str(e), flush=True)
nc = NextcloudApp()
nc.log(LogLvl.ERROR, str(e))
nc.providers.task_processing.report_result(task["id"], error_message=str(e))
with suppress(Exception):
nc = NextcloudApp()
nc.log(LogLvl.ERROR, str(e))
nc.providers.task_processing.report_result(task["id"], error_message=str(e))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should serve the purpose, no? Or did you mean with the logger module?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, sometimes it's useful to output exceptions to logs, at least to debug or "info" level - so that it would be easier to diagnose problems later.

I also like "supress", a very good thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, yes logging there would be good. I was thinking along the lines that there was already an error that should be addressed, others were not relevant. Logging again doesn't hurt ✌️

Copy link
Member

@bigcat88 bigcat88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for the future:

except (NextcloudException, httpx.RequestError) as e:
    pass

this should catch all exceptions, I think

Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
Signed-off-by: Anupam Kumar <kyteinsky@gmail.com>
@kyteinsky kyteinsky merged commit b6059b1 into main Aug 22, 2024
2 checks passed
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.

2 participants