diff options
| author | Conrad Ludgate <conradludgate@gmail.com> | 2022-10-08 04:33:07 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-07 20:33:07 -0700 |
| commit | 5725f4b40b1c612d2059789cb95222ff3b0bf510 (patch) | |
| tree | 2c96c89860515efccd323b81c3be3b4e2b325ddf /atuin-client/src | |
| parent | Fix compatability with fish vi key bindings (#541) (diff) | |
| download | atuin-5725f4b40b1c612d2059789cb95222ff3b0bf510.zip | |
add some error messages (#510)
* add some error messages
* fmt
Diffstat (limited to 'atuin-client/src')
| -rw-r--r-- | atuin-client/src/api_client.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/atuin-client/src/api_client.rs b/atuin-client/src/api_client.rs index d0511f8e..5692fea0 100644 --- a/atuin-client/src/api_client.rs +++ b/atuin-client/src/api_client.rs @@ -9,7 +9,7 @@ use reqwest::{ use sodiumoxide::crypto::secretbox; use atuin_common::api::{ - AddHistoryRequest, CountResponse, LoginRequest, LoginResponse, RegisterResponse, + AddHistoryRequest, CountResponse, ErrorResponse, LoginRequest, LoginResponse, RegisterResponse, SyncHistoryResponse, }; @@ -58,7 +58,8 @@ pub async fn register( .await?; if !resp.status().is_success() { - bail!("failed to register user"); + let error = resp.json::<ErrorResponse>().await?; + bail!("failed to register user: {}", error.reason); } let session = resp.json::<RegisterResponse>().await?; @@ -77,7 +78,8 @@ pub async fn login(address: &str, req: LoginRequest) -> Result<LoginResponse> { .await?; if resp.status() != reqwest::StatusCode::OK { - bail!("invalid login details"); + let error = resp.json::<ErrorResponse>().await?; + bail!("invalid login details: {}", error.reason); } let session = resp.json::<LoginResponse>().await?; |
