1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-31 04:57:45 +00:00

extend error message for case when writer instanciation fails second time

This commit is contained in:
Ulrich Hornung 2024-03-02 13:23:16 +01:00
parent b3fd711c99
commit 294c9de3ae

View file

@ -1225,11 +1225,20 @@ impl ManageOutFiles for OutFiles {
} }
// And then try to instantiate the writer again // And then try to instantiate the writer again
// If this fails - give up and propagate the error // If this fails - give up and propagate the error
self[idx].maybe_writer = let result = settings
Some(settings.instantiate_current_writer( .instantiate_current_writer(self[idx].filename.as_str(), self[idx].is_new);
self[idx].filename.as_str(), if let Err(e) = result {
self[idx].is_new, let mut count = 0;
)?); for out_file in self {
if out_file.maybe_writer.is_some() {
count += 1;
}
}
return Err(USimpleError::new(e.raw_os_error().unwrap_or(1),
format!("Instantiation of writer failed due to error: {e:?}. Existing writer number: {count}")));
}
self[idx].maybe_writer = Some(result?);
Ok(self[idx].maybe_writer.as_mut().unwrap()) Ok(self[idx].maybe_writer.as_mut().unwrap())
} }
} }