Skip to content

Commit

Permalink
chore: add a dedicated "refresh error"
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed Apr 18, 2024
1 parent 569f4d9 commit 77408d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/agent/client/oauth2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Client for OAuth2Client {
.request_async(async_http_client)
.await
.map_err(|err| {
OAuth2Error::LoginResult(format!("failed to exchange refresh token: {err}"))
OAuth2Error::Refresh(format!("failed to exchange refresh token: {err}"))
})?;

Ok((Self::make_authenticated(result), session_state))
Expand Down
2 changes: 1 addition & 1 deletion src/agent/client/openid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ impl Client for OpenIdClient {
.request_async(async_http_client)
.await
.map_err(|err| {
OAuth2Error::LoginResult(format!("failed to exchange refresh token: {err}"))
OAuth2Error::Refresh(format!("failed to exchange refresh token: {err}"))
})?;

Ok((
Expand Down
3 changes: 3 additions & 0 deletions src/agent/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub enum OAuth2Error {
StartLogin(String),
/// Failed to handle login result
LoginResult(String),
/// Failed to handle token refresh
Refresh(String),
/// Failing storing information
Storage(String),
/// Internal error
Expand All @@ -25,6 +27,7 @@ impl Display for OAuth2Error {
Self::Configuration(err) => write!(f, "configuration error: {err}"),
Self::StartLogin(err) => write!(f, "start login error: {err}"),
Self::LoginResult(err) => write!(f, "login result: {err}"),
Self::Refresh(err) => write!(f, "refresh error: {err}"),
Self::Storage(err) => write!(f, "storage error: {err}"),
Self::Internal(err) => write!(f, "internal error: {err}"),
}
Expand Down

0 comments on commit 77408d3

Please sign in to comment.