Add error code into Error MatchStatus #322
Conversation
… header response checking
…ve-data-scanner into fbryden/match_pairing
1a1d484 to
fa44a49
Compare
fbryden
left a comment
There was a problem hiding this comment.
LGTM!
Thank you very much !
| Partial, // Missing matches that are required for the match to be checked | ||
| Invalid, | ||
| Error(String), | ||
| Error(Option<u16>, String), |
There was a problem hiding this comment.
This is confusing to have this as a tuple element with no documentation. Is this always going to be an HTTP code?
There was a problem hiding this comment.
yes, it is an HTTP code always
let me see if i can add more context so the content is clear
There was a problem hiding this comment.
Updated to set property names explicit:
Error { code: Option<u16>, message: String },
There was a problem hiding this comment.
I see. Ok, looking at your tests and such, it looks like you're handling two semantically separate errors within the Error enum variant (which you use the presence of Option<u16> to distinguish).
In Rust, that is generally not a good pattern because of how ergonomic matching on sum types is.
@fbryden this is more of a question for how you want to design the API. What do you think about something like
pub enum MatchStatus {
// ...
HttpError { code: u16 }
// ...
OtherError(String)
}or, if you want better encapsulation you can have the validation errors be their own enum, like MatchStatus::Error(ValidationError::Http { code: 500 })
There was a problem hiding this comment.
Yeah that's a great point Jason, thank you for raising that.
Indeed I think I'll rework the error types a bit.
@gillarramendi I'll open a new PR with new error types - and you can base your PR off of that one? Sorry it's a new set of changes 🙈
|
closing in favor of #325 |
datadog-static-analyzerfbryden/match_pairingworking branch