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)

This commit is contained in:
Oliver Stöneberg 2014-09-08 18:46:40 +00:00
parent eb9a3ddc70
commit 82a99c4452
4 changed files with 30 additions and 11 deletions

View File

@ -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());

View File

@ -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());

View File

@ -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 _ElementType>
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() { }

View File

@ -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);