Skip to content

Add a generic client error #67

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

Merged
merged 3 commits into from
Jul 23, 2024
Merged

Add a generic client error #67

merged 3 commits into from
Jul 23, 2024

Conversation

tclem
Copy link
Member

@tclem tclem commented Jul 19, 2024

Fixes #16

I wanted to sketch out a way to allow middleware to return custom errors. What do people think about this approach? @jorendorff?

If we like this, I can add a test and maybe an example usage.

@tclem tclem requested a review from a team as a code owner July 19, 2024 22:45

/// A generic error that can be used by custom middleware.
#[error(transparent)]
Generic(#[from] GenericError),
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that seems good.

Suggestion: The variant could be called MiddlewareError.

Concern: This requires a crate version bump because it's a breaking change.

If you'd like the freedom to add more error variants in the future, add #[non_exhaustive] to the enum. But note that this is itself a breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Renamed. And I added #[non_exhaustive] since this is already a breaking change.

Concern: This requires a crate version bump because it's a breaking change.

We don't actually have a formal release yet (though we should do this), but I agree about the version bump.

Copy link
Contributor

@jorendorff jorendorff left a comment

Choose a reason for hiding this comment

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

Approved assuming the necessary version bump is added.

@tclem tclem added this pull request to the merge queue Jul 23, 2024
Merged via the queue into main with commit 7992a6a Jul 23, 2024
2 checks passed
@tclem tclem deleted the tclem/generic-client-error branch July 23, 2024 00:10
@CleanCut
Copy link
Contributor

This PR was included in v0.8.0, released today.

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.

Middleware errors are hard to use
3 participants