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

Make statuscode from u16 in error #216

Merged
merged 2 commits into from
Aug 7, 2020
Merged

Make statuscode from u16 in error #216

merged 2 commits into from
Aug 7, 2020

Conversation

yusuke-ota
Copy link
Contributor

@yusuke-ota yusuke-ota commented Aug 7, 2020

Enable http-types::Error::new(u16, Error), http-types::Error::from_str(u16, &str)

Description

Change Error::new(StatusCode, impl Into<anyhow::Error>) to Error::new(impl TryInto<StatusCode>, impl Into<anyhow::Error>).

Maybe, new tests I added are needless.
Before this pull request merge, please tell me. I`ll remove them.

Motivation and Context

A Part of tide#649

This enable Error::new(u16, error) like Response::new(u16).

How Has This Been Tested?

Add tests.
But, maybe these tests are needless after marge.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

change status that Error::new and Error::from_str argument
status: StatusCode
->
status: S
S: TryInto<StatusCode>
S::Error: Debug
Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

A few nits; but this looks 💯 overall!

tests/error.rs Outdated
#[should_panic]
fn fail_test_u16_into_status_code_in_http_types_error_from_str() {
let _http_types_error = Error::from_str(1000, "Un Existed");
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a newline here?

tests/error.rs Outdated Show resolved Hide resolved
@yusuke-ota
Copy link
Contributor Author

Thanks for reviewing. Your suggestion commit at f26568c.
If tests I added are needless, Please tell me.
If not, please merge this.

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

💯 thanks so much!

@yoshuawuyts yoshuawuyts merged commit d4f85be into http-rs:master Aug 7, 2020
@yusuke-ota yusuke-ota deleted the make_statuscode_from_u16_in_error branch August 8, 2020 01:10
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.

2 participants