diff options
author | 2023-04-08 02:38:31 +1000 | |
---|---|---|
committer | 2023-04-08 02:38:31 +1000 | |
commit | 2b424f5a8090961db0d8224f755b2dff7c9e9a8c (patch) | |
tree | 97da90487cbdefff24bcccc57f8a874b9ac8c929 /src/emu/image.cpp | |
parent | 9bda81283d963ee04dba90901f89c6f264ed3f3b (diff) |
Restored ability of for image devices to report specific error messages.
Restores ability to give specific/detailed messages removed in
6f7e4141ea14acaaf9cb973c66788fabb3457023 while pandering to obsession
with single return value.
Moved responsibility for displaying the error message in the UI to the
caller rather than device_image_interface, and made
device_image_interface always log the error along with the full path and
error condition content.
Gave several image devices more detailed error messages. Added some
FIXME comments for apparent bugs.
Diffstat (limited to 'src/emu/image.cpp')
-rw-r--r-- | src/emu/image.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/emu/image.cpp b/src/emu/image.cpp index 241b117f12f..b808c599250 100644 --- a/src/emu/image.cpp +++ b/src/emu/image.cpp @@ -51,27 +51,23 @@ image_manager::image_manager(running_machine &machine) if (!startup_image.empty()) { // we do have a startup image specified - load it - std::error_condition result = image_error::UNSPECIFIED; + std::pair<std::error_condition, std::string> result(image_error::UNSPECIFIED, std::string()); // try as a softlist if (software_name_parse(startup_image)) result = image.load_software(startup_image); // failing that, try as an image - if (result) + if (result.first) result = image.load(startup_image); // failing that, try creating it (if appropriate) - if (result && image.support_command_line_image_creation()) + if (result.first && image.support_command_line_image_creation()) result = image.create(startup_image); // did the image load fail? - if (result) + if (result.first) { - // retrieve image error message - std::string image_err = std::string(result.message()); - std::string startup_image_name = startup_image; - // unload the bad image image.unload(); @@ -80,11 +76,18 @@ image_manager::image_manager(running_machine &machine) if (machine.options().write_config()) write_config(machine.options(), nullptr, &machine.system()); - throw emu_fatalerror(EMU_ERR_DEVICE, "Device %s load (-%s %s) failed: %s", + // retrieve image error message + throw emu_fatalerror(EMU_ERR_DEVICE, + !result.second.empty() + ? "Device %1$s load (-%2$s %3$s) failed: %4$s (%5$s:%6$d %7$s)" + : "Device %1$s load (-%2$s %3$s) failed: %7$s (%5$s:%6$d)", image.device().name(), image.instance_name(), - startup_image_name, - image_err); + startup_image, + result.second, + result.first.category().name(), + result.first.value(), + result.first.message()); } } } @@ -243,13 +246,14 @@ void image_manager::postdevice_init() /* make sure that any required devices have been allocated */ for (device_image_interface &image : image_interface_enumerator(machine().root_device())) { - std::error_condition result = image.finish_load(); + auto [result, image_err] = image.finish_load(); /* did the image load fail? */ if (result) { /* retrieve image error message */ - std::string image_err = std::string(result.message()); + if (image_err.empty()) + image_err = result.message(); /* unload all images */ unload_all(); |