Use improved error message generation

This commit is contained in:
Jaby 2022-11-17 02:18:24 +01:00 committed by Jaby
parent 910e8ede11
commit 0bfadfe2f5
2 changed files with 8 additions and 6 deletions

View File

@ -2,7 +2,7 @@ use super::{*, SectorWriter, {CDDesc, Error}};
use super::super::types::{helper::{DirectoryRecordMember, PathTableMember}, layout::Layout, *}; use super::super::types::{helper::{DirectoryRecordMember, PathTableMember}, layout::Layout, *};
use builder::SubModeBuilder; use builder::SubModeBuilder;
use cdtypes::types::{cdstring::{AString, DString}, date::*, dir_record::*, helper::{round_bytes_mode2_form1, sector_count_mode2_form1}, path_table::*, pvd as cd_pvd, lsb_msb::*, sector::Mode2Form1}; use cdtypes::types::{cdstring::{AString, DString}, date::*, dir_record::*, helper::{round_bytes_mode2_form1, sector_count_mode2_form1}, path_table::*, pvd as cd_pvd, lsb_msb::*, sector::Mode2Form1};
use tool_helper::{BufferedInputFile, construct_from_error_if as format_if_error, open_input_file_buffered}; use tool_helper::{BufferedInputFile, format_if_error, open_input_file_buffered};
use std::io::{Read, Seek, SeekFrom}; use std::io::{Read, Seek, SeekFrom};
const ROOT_DIR_NAME:&'static str = "\x00"; const ROOT_DIR_NAME:&'static str = "\x00";
@ -148,10 +148,12 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit
Ok(()) Ok(())
} }
write_data_zeros(sec_writer)?; format_if_error!(write_data_zeros(sec_writer), "Writing license data zeros failed with: {error_text}")?;
write_license_string(sec_writer, &mut license_file)?; format_if_error!(write_license_string(sec_writer, &mut license_file), "Writing license string from file failed with: {error_text}")?;
write_license_logo(sec_writer, &mut license_file)?; format_if_error!(write_license_logo(sec_writer, &mut license_file), "Writing license logo from file failed with: {error_text}")?;
write_audio_zeros(sec_writer) format_if_error!(write_audio_zeros(sec_writer), "Writing license audio zeros failed with: {error_text}")?;
Ok(())
} }
let system_area_lba = system_area.track_rel_lba; let system_area_lba = system_area.track_rel_lba;

View File

@ -8,7 +8,7 @@ pub type Output = Box<dyn Write>;
pub type Input = Box<dyn Read>; pub type Input = Box<dyn Read>;
#[macro_export] #[macro_export]
macro_rules! construct_from_error_if { macro_rules! format_if_error {
($result:expr, $format_text:literal) => { ($result:expr, $format_text:literal) => {
tool_helper::callback_if_error($result, |error_text| { tool_helper::callback_if_error($result, |error_text| {
format!($format_text, error_text=error_text) format!($format_text, error_text=error_text)