Skip to content

Commit 44f485b

Browse files
committed
error handling refactor
1 parent a76809d commit 44f485b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/sheets.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ pub(crate) async fn sheets_client(
3939
original_uri: Uri,
4040
) -> Result<SheetsClient, Error> {
4141
let maybe_token = if let Some(auth_header) = headers.get("x-authorization-google") {
42-
let token = auth_header.to_str().unwrap_or_default().to_string();
42+
let token = match auth_header.to_str() {
43+
Ok(s) => Some(s.to_string()),
44+
Err(e) => {
45+
return Err(Error::UserFacing(format!(
46+
"Invalid token in the header: {}",
47+
e
48+
)))
49+
}
50+
};
4351
Some(token)
4452
} else {
4553
session

0 commit comments

Comments
 (0)