From 82a99c44523567b268803f2d3f48c8caaf7ae9a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20St=C3=B6neberg?= Date: Mon, 8 Sep 2014 18:46:40 +0000 Subject: [PATCH] moved tagged_list:: out of tagged_list to make it catch-able / handle add_exception / updated exception handling unidasm to match the main one and return a proper exitcode in case of an error (nw) --- src/emu/clifront.c | 5 +++++ src/emu/machine.c | 5 +++++ src/lib/util/tagmap.h | 18 +++++++++--------- src/tools/unidasm.c | 13 +++++++++++-- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/emu/clifront.c b/src/emu/clifront.c index cf687872272..b8454363bb2 100644 --- a/src/emu/clifront.c +++ b/src/emu/clifront.c @@ -274,6 +274,11 @@ int cli_frontend::execute(int argc, char **argv) osd_printf_error("Caught unhandled emulator exception\n"); m_result = MAMERR_FATALERROR; } + catch (add_exception &aex) + { + osd_printf_error("Tag '%s' already exists in tagged_list\n", aex.tag()); + m_result = MAMERR_FATALERROR; + } catch (std::exception &ex) { osd_printf_error("Caught unhandled %s exception: %s\n", typeid(ex).name(), ex.what()); diff --git a/src/emu/machine.c b/src/emu/machine.c index 5b134e74f85..80247d7820c 100644 --- a/src/emu/machine.c +++ b/src/emu/machine.c @@ -414,6 +414,11 @@ int running_machine::run(bool firstrun) osd_printf_error("Error performing a late bind of type %s to %s\n", btex.m_actual_type.name(), btex.m_target_type.name()); error = MAMERR_FATALERROR; } + catch (add_exception &aex) + { + osd_printf_error("Tag '%s' already exists in tagged_list\n", aex.tag()); + error = MAMERR_FATALERROR; + } catch (std::exception &ex) { osd_printf_error("Caught unhandled %s exception: %s\n", typeid(ex).name(), ex.what()); diff --git a/src/lib/util/tagmap.h b/src/lib/util/tagmap.h index e31b6671108..3a0a57f8117 100644 --- a/src/lib/util/tagmap.h +++ b/src/lib/util/tagmap.h @@ -194,6 +194,15 @@ private: // ======================> tagged_list +class add_exception +{ +public: + add_exception(const char *tag) : m_tag(tag) { } + const char *tag() const { return m_tag; } +private: + const char *m_tag; +}; + // a tagged_list is a class that maintains a list of objects that can be quickly looked up by tag template class tagged_list @@ -203,15 +212,6 @@ class tagged_list tagged_list &operator=(const tagged_list &); public: - class add_exception - { - public: - add_exception(const char *tag) : m_tag(tag) { } - const char *tag() const { return m_tag; } - private: - const char *m_tag; - }; - // construction tagged_list() { } diff --git a/src/tools/unidasm.c b/src/tools/unidasm.c index 6b03c2d7cad..0101de8a258 100644 --- a/src/tools/unidasm.c +++ b/src/tools/unidasm.c @@ -644,20 +644,29 @@ int main(int argc, char *argv[]) catch (emu_fatalerror &fatal) { fprintf(stderr, "%s\n", fatal.string()); + result = 1; if (fatal.exitcode() != 0) result = fatal.exitcode(); } catch (emu_exception &) { fprintf(stderr, "Caught unhandled emulator exception\n"); + result = 1; } - catch (std::bad_alloc &) + catch (add_exception &aex) { - fprintf(stderr, "Out of memory!\n"); + fprintf(stderr, "Tag '%s' already exists in tagged_list\n", aex.tag()); + result = 1; + } + catch (std::exception &ex) + { + fprintf(stderr, "Caught unhandled %s exception: %s\n", typeid(ex).name(), ex.what()); + result = 1; } catch (...) { fprintf(stderr, "Caught unhandled exception\n"); + result = 1; } osd_free(data);