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

chore(volo-http): refactor client error #395

Merged
merged 6 commits into from
Apr 1, 2024

Conversation

wfly1998
Copy link
Member

@wfly1998 wfly1998 commented Apr 1, 2024

Motivation

The previous client error is not general enough, and with mod error introduced, rejection error should also be in the mod.

And this PR introduces a new config fail_on_error_status for client. If it is enabled, server response with 4xx or 5xx status will be converted to ClientError with ErrorKind::Status.

In addition, some methods of ClientBuiler are fn foo(self, xxx) -> Self, and some methods are fn bar(&mut self, xxx) -> &mut Self. This PR also unifies them to fn bar(&mut self, xxx) -> &mut Self, because it may be passed to somewhere as &mut ClientBuilder, it is more convenient.

Solution

  • Refactor client error from ClientErrorInner to Option<BoxError> and Option<Uri>
  • Move RejectionError from server::extract to error::server
  • Change most fn foo(self, xxx) -> Self to fn bar(&mut self, xxx) -> &mut Self for ClientBuilder.

Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
Signed-off-by: Yu Li <liyu.yukiteru@bytedance.com>
@wfly1998 wfly1998 requested review from a team as code owners April 1, 2024 04:10
@wfly1998 wfly1998 enabled auto-merge (squash) April 1, 2024 05:29
@wfly1998 wfly1998 merged commit 7f1a479 into cloudwego:main Apr 1, 2024
11 of 13 checks passed
@wfly1998 wfly1998 deleted the chore/http-error branch April 1, 2024 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants