Skip to content

propagate panics as errors to callers #35

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
2bndy5 opened this issue Sep 18, 2024 · 0 comments · Fixed by #47
Closed

propagate panics as errors to callers #35

2bndy5 opened this issue Sep 18, 2024 · 0 comments · Fixed by #47
Assignees
Labels
bug Something isn't working

Comments

@2bndy5
Copy link
Collaborator

2bndy5 commented Sep 18, 2024

Currently, there are a lot of places where I use Result.expect() to panic on unexpected behavior. Most notably in RestApiClient.send_api_request(). It is more idiomatic rust to handle errors in the caller instead of arbitrarily throwing panics.

This solution may be considered a refactor since there are so many instances where the code calls Result.expect(), or Result.unwrap() (same as .expect() but without customized error message).

Note

There are some instances where it makes sense to use .unwrap(), but it should be determined by the code block's local context.

TBH, this problem was born from the fact that this is my first rust project. I should have picked a more robust design from the start.

@2bndy5 2bndy5 added the enhancement New feature or request label Sep 18, 2024
@2bndy5 2bndy5 self-assigned this Sep 18, 2024
@2bndy5 2bndy5 added bug Something isn't working and removed enhancement New feature or request labels Sep 25, 2024
@2bndy5 2bndy5 linked a pull request Sep 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant