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

Better error handling, pattern matching instead of conditional flow #137

Closed
wants to merge 12 commits into from
Closed

Conversation

0xDmtri
Copy link
Contributor

@0xDmtri 0xDmtri commented Mar 6, 2024

Description

Improved error handling and exhaustive handling of all the possible error codes. In original implementation only two variants of enum were handled in conditional manner (which is not robust in this case). The proposed usage of pattern matching via "match" case is a better way of handling errors. I have proposed a new enum variant for an Error that returns the standardized error code instead.

Let me know if there are any further suggestions for improvement.

Checklist

  • [+] Formatted code using cargo fmt --all
  • [+] Linted code using clippy
    • [+] with reqwest feature: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,reqwest-client -- -D warnings
    • [+] with surf feature: cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features use-serde,derive,hyper-client -- -D warnings
  • [+] Updated README.md using cargo doc2readme -p influxdb --expand-macros
  • [+] Reviewed the diff. Did you leave any print statements or unnecessary comments?
  • [+] Any unfinished work that warrants a separate issue captured in an issue with a TODO code comment

influxdb/src/client/mod.rs Outdated Show resolved Hide resolved
msrd0
msrd0 previously requested changes Mar 7, 2024
influxdb/src/error.rs Show resolved Hide resolved
@msrd0 msrd0 dismissed their stale review March 10, 2024 19:28

outdated

Copy link
Collaborator

@msrd0 msrd0 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes! I've added a few more comments, it would be great if you could address those as well (sorry for missing the problem in the tests in my last review)

influxdb/src/client/mod.rs Outdated Show resolved Hide resolved
influxdb/src/error.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests_v2.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests_v2.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests_v2.rs Outdated Show resolved Hide resolved
influxdb/tests/integration_tests_v2.rs Outdated Show resolved Hide resolved
@0xDmtri 0xDmtri closed this Mar 11, 2024
@msrd0
Copy link
Collaborator

msrd0 commented Mar 11, 2024

Did you intentionally or accidentially close this PR? If the former, would you be ok if we used your changes as a base for a new PR?

@0xDmtri
Copy link
Contributor Author

0xDmtri commented Mar 12, 2024

Did you intentionally or accidentially close this PR? If the former, would you be ok if we used your changes as a base for a new PR?

Hey, intentionally because of the mess I made there haha. I am on track of redesigning my previous logic into something better. I will make a new PR today in the evening. Sounds good?

@msrd0
Copy link
Collaborator

msrd0 commented Mar 12, 2024

Sounds good 👍

@0xDmtri 0xDmtri mentioned this pull request Mar 13, 2024
7 tasks
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.

3 participants