-
Notifications
You must be signed in to change notification settings - Fork 79
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 Errors #150
Better Errors #150
Conversation
Well, surf uses
I am not sure what your plan is with this struct. If it's just a wrapper over |
Sure, sure, I was just not sure if you are ok with a primitive. On it. |
Pushed |
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 the changes. There is a test failure, could you take a look?
I think that failing tests are the result of our new error handling. Currently, you were only handling unauthorized or unauthenticated requests. However, as you can see in the code actions, the error code that causes tests fail is ApiError(400). This has not been handled before. |
@msrd0 have you had a chance to look at my comment above? |
Yes, I did have a look and it seems like you changed the code so that something that already didn't work now actually fails. I had asked @Empty2k12 to take a look but haven't heard back yet. |
if u want, im happy to take it and fix it. |
Sorry for the delay. I am taking a look now. |
I think I have found the problem. Will push momentarily. We should consider exposing the |
Good idea imho |
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.
Looks good. I will create a separate issue for adapting the errors further to include the error message from InfluxDB.
Description
Slightly reworked PR #137.
Still not ready as further discussion has to be done before I can finalize it.
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.
TODO:
FIXME:
Currently, as we are using both surf and reqwest, the StatusCode is a problem as both crates have their distinct types with different methods (one of the ideas was to use .as_u16() and store it as u16 inside the error enum, however, surf does not have such method implemented).
I tried a few things but seemed to be unable to come up with a unified solution that would pass all the GH workflows.
What I propose?
I propose making our own StatusCode with trait impl for all of the above types of StatusCode. This way, we will be able to have a cleaner code with just a single .into(), instead of adding bunch of feature gated imports etc.
Plz, let me know what you think.
Checklist
cargo fmt --all
cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,reqwest-client-rustls -- -D warnings
cargo clippy --manifest-path influxdb/Cargo.toml --all-targets --no-default-features --features serde,derive,hyper-client -- -D warnings
cargo doc2readme -p influxdb --expand-macros