From 0bfadfe2f5e7eab01be0a8178749a378b8bddd85 Mon Sep 17 00:00:00 2001 From: Jaby Date: Thu, 17 Nov 2022 02:18:24 +0100 Subject: [PATCH] Use improved error message generation --- src/Tools/psxcdgen_ex/src/encoder/psx.rs | 12 +++++++----- src/Tools/tool_helper/src/lib.rs | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Tools/psxcdgen_ex/src/encoder/psx.rs b/src/Tools/psxcdgen_ex/src/encoder/psx.rs index 9fa0e726..4cb9e60d 100644 --- a/src/Tools/psxcdgen_ex/src/encoder/psx.rs +++ b/src/Tools/psxcdgen_ex/src/encoder/psx.rs @@ -2,7 +2,7 @@ use super::{*, SectorWriter, {CDDesc, Error}}; use super::super::types::{helper::{DirectoryRecordMember, PathTableMember}, layout::Layout, *}; 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 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}; const ROOT_DIR_NAME:&'static str = "\x00"; @@ -148,10 +148,12 @@ fn process_system_area(system_area: &SystemArea, sec_writer: &mut dyn SectorWrit Ok(()) } - write_data_zeros(sec_writer)?; - write_license_string(sec_writer, &mut license_file)?; - write_license_logo(sec_writer, &mut license_file)?; - write_audio_zeros(sec_writer) + format_if_error!(write_data_zeros(sec_writer), "Writing license data zeros failed with: {error_text}")?; + format_if_error!(write_license_string(sec_writer, &mut license_file), "Writing license string from file failed with: {error_text}")?; + format_if_error!(write_license_logo(sec_writer, &mut license_file), "Writing license logo from file failed with: {error_text}")?; + 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; diff --git a/src/Tools/tool_helper/src/lib.rs b/src/Tools/tool_helper/src/lib.rs index 134d2d71..630ce824 100644 --- a/src/Tools/tool_helper/src/lib.rs +++ b/src/Tools/tool_helper/src/lib.rs @@ -8,7 +8,7 @@ pub type Output = Box; pub type Input = Box; #[macro_export] -macro_rules! construct_from_error_if { +macro_rules! format_if_error { ($result:expr, $format_text:literal) => { tool_helper::callback_if_error($result, |error_text| { format!($format_text, error_text=error_text)