You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like to log the Display version of an error instead of the Debug version, because it's then all on one line which I like better for logfiles. However there is currently no way to log the original error. I would like to be able to do:
let content = fs::read(&path)
.with_context(|e| format!("failed to read instrs from {}: {}", path.display(), e));
I would recommend not putting the cause's message into the outer error's message. Instead you can print the causes in whatever formatting you want, such as separated by ::
I like to log the Display version of an error instead of the Debug version, because it's then all on one line which I like better for logfiles. However there is currently no way to log the original error. I would like to be able to do:
It's probably too late to change
with_context
to take an argument - besides, it would not make sense forOption
s. Maybeerror_context
? POC here: https://github.com/miquels/anyhow/commit/4a79660fa0588c097b9ae3d143bb7e54b928b97bThe text was updated successfully, but these errors were encountered: