Skip to content

Commit

Permalink
cookie: better error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Engelhardt <[email protected]>
  • Loading branch information
antonengelhardt committed Mar 6, 2024
1 parent 86969f5 commit e7418f1
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ impl Session {
let decoded_cookie = match base64engine.decode(encoded_cookie.as_bytes()) {
Ok(cookie) => cookie,
Err(e) => {
warn!("the cookie didn't match the expected format: {}", e);
return Err(e.to_string());
return Err(format!("decoding the cookie failed: {}", e.to_string()));
}
}; // TODO: Idiomatically handle the error

Expand All @@ -166,17 +165,14 @@ impl Session {
Ok(session)
}
// If the cookie cannot be parsed into a struct, return an error
Err(e) => {
warn!("the cookie didn't match the expected format: {}", e);
Err(e.to_string())
}
Err(e) => Err(format!(
"the cookie didn't match the expected format: {}",
e.to_string()
)),
}
}
// If decryption failed, return an error
Err(e) => {
warn!("decryption failed: {}", e.to_string());
Err(e.to_string())
}
Err(e) => Err(format!("decryption failed: {}", e.to_string())),
}
}
}

0 comments on commit e7418f1

Please sign in to comment.