Fix missing details when logging errors

This commit is contained in:
Oliver Hamlet
2025-03-25 20:56:11 +00:00
parent 99f81ca783
commit 9dc14da0ba
3 changed files with 17 additions and 4 deletions
+5 -2
View File
@@ -6,7 +6,10 @@ use std::{
};
use super::error::{ArchiveParsingError, ArchivePathParsingError};
use crate::{logging, plugin::has_ascii_extension};
use crate::{
logging::{self, format_details},
plugin::has_ascii_extension,
};
use super::{ba2, bsa};
@@ -25,7 +28,7 @@ pub fn assets_in_archives(archive_paths: &[PathBuf]) -> BTreeMap<u64, BTreeSet<u
logging::error!(
"Encountered an error while trying to read the Bethesda archive at \"{}\": {}",
archive_path.display(),
e
format_details(&e)
);
continue;
}
+2 -2
View File
@@ -14,7 +14,7 @@ use crate::{
DatabaseLockPoisonError, GameHandleCreationError, LoadOrderError, LoadOrderStateError,
LoadPluginsError, SortPluginsError,
},
logging,
logging::{self, format_details},
metadata::{
Filename,
plugin_metadata::{GHOST_FILE_EXTENSION, iends_with_ascii},
@@ -657,7 +657,7 @@ fn try_load_plugin(
logging::error!(
"Caught error while trying to load \"{}\": {}",
plugin_path.display(),
e
format_details(&e)
);
None
}
+10
View File
@@ -95,6 +95,16 @@ macro_rules! trace {
pub(crate) use {debug, error, info, log, trace, warning as warn};
pub(crate) fn format_details<E: std::error::Error>(error: &E) -> String {
let mut details = error.to_string(); // The display string.
if let Some(source) = error.source() {
details += ": ";
details += &format_details(&source)
}
details
}
#[cfg(test)]
mod tests {
use super::*;