Skip to content

Commit 5cfd024

Browse files
committed
refactor: traverse error source
1 parent 2f9ec68 commit 5cfd024

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "init4-bin-base"
33

44
description = "Internal utilities for binaries produced by the init4 team"
55
keywords = ["init4", "bin", "base"]
6-
version = "0.18.0-rc.4"
6+
version = "0.18.0-rc.5"
77
edition = "2021"
88
rust-version = "1.85"
99
authors = ["init4", "James Prestwich", "evalir"]

src/perms/oauth.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,19 @@ impl Authenticator {
168168
debug!("Successfully refreshed oauth token");
169169
}
170170
Err(err) => {
171-
let err_source = err.source().map(|e| e.to_string());
172-
error!(%err, err_source, "Failed to refresh oauth token");
171+
let mut current = &err as &dyn Error;
172+
173+
// This is a little hacky, but the oauth library nests
174+
// errors quite deeply, so we need to walk the source chain
175+
// to get the full picture.
176+
let mut source_chain = Vec::new();
177+
while let Some(source) = current.source() {
178+
source_chain.push(source.to_string());
179+
current = source;
180+
}
181+
let source_chain = source_chain.join("\n\n Caused by: \n");
182+
183+
error!(%err, %source_chain, "Failed to refresh oauth token");
173184
}
174185
};
175186
let _sleep = tokio::time::sleep(tokio::time::Duration::from_secs(interval)).await;

0 commit comments

Comments
 (0)