mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Fix missing details when logging errors
This commit is contained in:
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
@@ -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::*;
|
||||
|
||||
Reference in New Issue
Block a user