Clean up error handling
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use tool_helper::{Input, Output};
|
||||
use std::io::Read;
|
||||
pub use tool_helper::Error;
|
||||
pub use tool_helper::{Error, format_if_error};
|
||||
|
||||
pub enum LineFeed {
|
||||
Unix,
|
||||
@@ -92,12 +92,11 @@ pub fn convert(cfg: Configuration, input: Input, mut output: Output) -> Result<(
|
||||
}
|
||||
};
|
||||
|
||||
let action = String::from("Writing source file");
|
||||
if is_source_file {
|
||||
Error::try_or_new_with_action(action, write_source_file(input, &mut output, declarations, cfg.data_name, line_feed))
|
||||
format_if_error!(write_source_file(input, &mut output, declarations, cfg.data_name, line_feed), "Writing source file failed with: \"{error_text}\"")
|
||||
}
|
||||
|
||||
else {
|
||||
Error::try_or_new_with_action(action, write_header_file(input, &mut output, cfg.file_name, declarations, cfg.data_name, line_feed))
|
||||
format_if_error!(write_header_file(input, &mut output, cfg.file_name, declarations, cfg.data_name, line_feed), "Writing header file failed with: \"{error_text}\"")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user