Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions crates/plume_core/src/auth/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ use crate::Error;
pub async fn parse_response(
res: Result<Response, reqwest::Error>,
) -> Result<plist::Dictionary, Error> {
let res = res?.text().await?;
let res: plist::Dictionary = plist::from_bytes(res.as_bytes())?;
let res = res?;
let status = res.status();

if !status.is_success() {
return Err(Error::GeneralHttpError {
url: res.url().to_string(),
status: status.as_u16(),
// body: res.text().await?,
})
}

let text = res.text().await?;
let res: plist::Dictionary = plist::from_bytes(text.as_bytes())?;
let res: plist::Value = res.get("Response").unwrap().to_owned();
match res {
plist::Value::Dictionary(dict) => Ok(dict),
Expand Down
9 changes: 9 additions & 0 deletions crates/plume_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ pub enum Error {
http_code: Option<u16>,
message: String,
},
/// We don't print out the response content because it generally does not matter too much,
/// and if we display this in a menu then it will probably be way too big.
/// I leave it in for ease of debugging.
#[error("HTTP request error {status} attempting to connect to {url}")]
GeneralHttpError {
url: String,
status: u16,
// body: String,
},
#[error("Request to developer session failed")]
DeveloperSessionRequestFailed,
#[error("Authentication SRP error {0}: {1}")]
Expand Down