diff options
author | Conrad Ludgate <conrad.ludgate@truelayer.com> | 2022-04-21 08:05:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-21 08:05:57 +0100 |
commit | 48747e3b7c542c696003f71ef4b4ae457934e57c (patch) | |
tree | 0bbde7136b84cda46cdb758d2cbeda67ca436ee8 /atuin-client/src/api_client.rs | |
parent | ed4e07d2e63af1584a262037781729a5144a5502 (diff) |
A few minor tweaks (#314)
* use bail macro
replace client database errors
remove dead code
* fix test
Diffstat (limited to 'atuin-client/src/api_client.rs')
-rw-r--r-- | atuin-client/src/api_client.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs index 87c4b6a45..171012acd 100644 --- a/atuin-client/src/api_client.rs +++ b/atuin-client/src/api_client.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use chrono::Utc; -use eyre::{eyre, Result}; +use eyre::{bail, Result}; use reqwest::header::{HeaderMap, AUTHORIZATION, USER_AGENT}; use reqwest::{StatusCode, Url}; use sodiumoxide::crypto::secretbox; @@ -41,7 +41,7 @@ pub async fn register( let resp = reqwest::blocking::get(url)?; if resp.status().is_success() { - return Err(eyre!("username already in use")); + bail!("username already in use"); } let url = format!("{}/register", address); @@ -54,7 +54,7 @@ pub async fn register( .await?; if !resp.status().is_success() { - return Err(eyre!("failed to register user")); + bail!("failed to register user"); } let session = resp.json::<RegisterResponse>().await?; @@ -73,7 +73,7 @@ pub async fn login(address: &str, req: LoginRequest) -> Result<LoginResponse> { .await?; if resp.status() != reqwest::StatusCode::OK { - return Err(eyre!("invalid login details")); + bail!("invalid login details"); } let session = resp.json::<LoginResponse>().await?; @@ -102,7 +102,7 @@ impl<'a> Client<'a> { let resp = self.client.get(url).send().await?; if resp.status() != StatusCode::OK { - return Err(eyre!("failed to get count (are you logged in?)")); + bail!("failed to get count (are you logged in?)"); } let count = resp.json::<CountResponse>().await?; |