Skip to content

Add error code into Error MatchStatus #322

Closed
gillarramendi wants to merge 48 commits intomainfrom
gotzon.illarramendi/match-status-error-code
Closed

Add error code into Error MatchStatus #322
gillarramendi wants to merge 48 commits intomainfrom
gotzon.illarramendi/match-status-error-code

Conversation

@gillarramendi
Copy link
Copy Markdown

@gillarramendi gillarramendi commented Feb 27, 2026

  • Add error code into Error MatchStatus in addition to the message
  • This will be later used to track validation errors on the datadog-static-analyzer
  • Linked PR on datadog-static-analyzer
  • PR created on top of fbryden/match_pairing working branch

fbryden and others added 30 commits February 9, 2026 11:27
@gillarramendi gillarramendi force-pushed the gotzon.illarramendi/match-status-error-code branch from 1a1d484 to fa44a49 Compare March 2, 2026 11:36
@gillarramendi gillarramendi changed the base branch from main to fbryden/match_pairing March 2, 2026 11:38
Copy link
Copy Markdown
Contributor

@fbryden fbryden left a comment

Choose a reason for hiding this comment

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

LGTM!
Thank you very much !

Copy link
Copy Markdown

@ChouraquiBen ChouraquiBen left a comment

Choose a reason for hiding this comment

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

LGTM

Partial, // Missing matches that are required for the match to be checked
Invalid,
Error(String),
Error(Option<u16>, String),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is confusing to have this as a tuple element with no documentation. Is this always going to be an HTTP code?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, it is an HTTP code always
let me see if i can add more context so the content is clear

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated to set property names explicit:
Error { code: Option<u16>, message: String },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 🙈

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

perfect!

Base automatically changed from fbryden/match_pairing to main March 2, 2026 16:14
@gillarramendi
Copy link
Copy Markdown
Author

closing in favor of #325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants