diff --git a/rust/gui-client/src-common/src/auth.rs b/rust/gui-client/src-common/src/auth.rs index 778a890d6..7623a30a2 100644 --- a/rust/gui-client/src-common/src/auth.rs +++ b/rust/gui-client/src-common/src/auth.rs @@ -28,8 +28,13 @@ pub enum Error { PathWrong, #[error("Couldn't read session file: {0}")] ReadFile(std::io::Error), - #[error("Could not (de)serialize session data")] - Serde, + #[error("Could not serialize session data")] + SerializeSession(#[source] serde_json::Error), + #[error("Could not deserialize session data ({json})")] + DeserializeSession { + source: serde_json::Error, + json: String, + }, #[error("State in server response doesn't match state in client request")] StatesDontMatch, #[error("Couldn't write session file: {0}")] @@ -212,7 +217,7 @@ impl Auth { save_file( &session_data_path()?, serde_json::to_string(session) - .map_err(|_| Error::Serde)? + .map_err(Error::SerializeSession)? .as_bytes(), )?; Ok(()) @@ -248,8 +253,9 @@ impl Auth { Err(e) => return Err(Error::ReadFile(e)), }; match std::fs::read_to_string(session_data_path()?) { - Ok(x) => { - session = serde_json::from_str(&x).map_err(|_| Error::Serde)?; + Ok(json) => { + session = serde_json::from_str(&json) + .map_err(|source| Error::DeserializeSession { source, json })?; } Err(e) if e.kind() == std::io::ErrorKind::NotFound => {} Err(e) => return Err(Error::ReadFile(e)),