mirror of
https://github.com/OMGeeky/yup-oauth2.git
synced 2025-12-31 00:20:04 +01:00
Rename Error::ClientError and RefreshError::ConnectionError to HttpError.
PollError already contained an HttpError variant so this makes all variants that contain a hyper::Error consistently named.
This commit is contained in:
@@ -153,7 +153,7 @@ impl DeviceFlow {
|
||||
.header(header::CONTENT_TYPE, "application/x-www-form-urlencoded")
|
||||
.body(hyper::Body::from(req))
|
||||
.unwrap();
|
||||
let resp = client.request(req).await.map_err(Error::ClientError)?;
|
||||
let resp = client.request(req).await?;
|
||||
// This return type is defined in https://tools.ietf.org/html/draft-ietf-oauth-device-flow-15#section-3.2
|
||||
// The alias is present as Google use a non-standard name for verification_uri.
|
||||
// According to the standard interval is optional, however, all tested implementations provide it.
|
||||
|
||||
12
src/error.rs
12
src/error.rs
@@ -71,7 +71,7 @@ impl StdError for PollError {
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
/// Indicates connection failure
|
||||
ClientError(hyper::Error),
|
||||
HttpError(hyper::Error),
|
||||
/// The server returned an error.
|
||||
NegativeServerResponse {
|
||||
/// The error code
|
||||
@@ -93,7 +93,7 @@ pub enum Error {
|
||||
|
||||
impl From<hyper::Error> for Error {
|
||||
fn from(error: hyper::Error) -> Error {
|
||||
Error::ClientError(error)
|
||||
Error::HttpError(error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ impl From<RefreshError> for Error {
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
||||
match *self {
|
||||
Error::ClientError(ref err) => err.fmt(f),
|
||||
Error::HttpError(ref err) => err.fmt(f),
|
||||
Error::NegativeServerResponse {
|
||||
ref error,
|
||||
ref error_description,
|
||||
@@ -148,7 +148,7 @@ impl fmt::Display for Error {
|
||||
impl StdError for Error {
|
||||
fn source(&self) -> Option<&(dyn StdError + 'static)> {
|
||||
match *self {
|
||||
Error::ClientError(ref err) => Some(err),
|
||||
Error::HttpError(ref err) => Some(err),
|
||||
Error::LowLevelError(ref err) => Some(err),
|
||||
Error::JSONError(ref err) => Some(err),
|
||||
_ => None,
|
||||
@@ -160,14 +160,14 @@ impl StdError for Error {
|
||||
#[derive(Debug)]
|
||||
pub enum RefreshError {
|
||||
/// Indicates connection failure
|
||||
ConnectionError(hyper::Error),
|
||||
HttpError(hyper::Error),
|
||||
/// The server did not answer with a new token, providing the server message
|
||||
ServerError(String, Option<String>),
|
||||
}
|
||||
|
||||
impl From<hyper::Error> for RefreshError {
|
||||
fn from(value: hyper::Error) -> Self {
|
||||
RefreshError::ConnectionError(value)
|
||||
RefreshError::HttpError(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -185,15 +185,8 @@ impl InstalledFlow {
|
||||
{
|
||||
let redirect_uri = self.flow_delegate.redirect_uri();
|
||||
let request = Self::request_token(app_secret, authcode, redirect_uri, server_addr);
|
||||
let resp = hyper_client
|
||||
.request(request)
|
||||
.await
|
||||
.map_err(Error::ClientError)?;
|
||||
let body = resp
|
||||
.into_body()
|
||||
.try_concat()
|
||||
.await
|
||||
.map_err(Error::ClientError)?;
|
||||
let resp = hyper_client.request(request).await?;
|
||||
let body = resp.into_body().try_concat().await?;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct JSONTokenResponse {
|
||||
|
||||
@@ -200,15 +200,8 @@ impl ServiceAccountFlow {
|
||||
.header(header::CONTENT_TYPE, "application/x-www-form-urlencoded")
|
||||
.body(hyper::Body::from(rqbody))
|
||||
.unwrap();
|
||||
let response = hyper_client
|
||||
.request(request)
|
||||
.await
|
||||
.map_err(Error::ClientError)?;
|
||||
let body = response
|
||||
.into_body()
|
||||
.try_concat()
|
||||
.await
|
||||
.map_err(Error::ClientError)?;
|
||||
let response = hyper_client.request(request).await?;
|
||||
let body = response.into_body().try_concat().await?;
|
||||
|
||||
/// This is the schema of the server's response.
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user