- Handle exceptions in jumpto dialog, simpy copying it from SimulationController

git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@1040 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
elvez 2006-09-07 11:28:08 +00:00
parent 80f559ec7b
commit a681f92dcb
1 changed files with 44 additions and 4 deletions

View File

@ -29,6 +29,7 @@
#include <sgpemv2/resource.hh> #include <sgpemv2/resource.hh>
#include <gtkmm/main.h> #include <gtkmm/main.h>
#include <gtkmm/messagedialog.h>
#ifndef NDEBUG #ifndef NDEBUG
#include <iostream> #include <iostream>
@ -86,7 +87,7 @@ JumpToDialog::_on_jump()
sim.attach(*this); sim.attach(*this);
bool reenable = h.is_notify_enabled(); bool reenable = h.is_notify_enabled();
try try
{ {
if(_target_instant < h.get_size() - 1) if(_target_instant < h.get_size() - 1)
sim.jump_to(_target_instant); sim.jump_to(_target_instant);
else else
@ -99,11 +100,50 @@ JumpToDialog::_on_jump()
if(sim.get_state() == Simulation::state_stopped) if(sim.get_state() == Simulation::state_stopped)
break; // Simulation ended before reaching _target_instant break; // Simulation ended before reaching _target_instant
} }
} }
catch(...) // TODO: exception handling copied from SimulationController, it should be factored out
catch(const UserInterruptException& uie)
{
// Show the user a dialog
MessageDialog diag(_("<b>The selected user CPU policy stopped before returning:</b>\n") + Markup::escape_text(uie.what()),
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
diag.run();
}
catch(const MalformedPolicyException& mpe)
{
// Show user a dialog
MessageDialog diag(_("<b>The selected user CPU policy was malformed and failed to sort the queue:</b>\n") +
Markup::escape_text(mpe.what()), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
diag.run();
try
{ {
// FIXME: correctly manage exceptions! // Deactivate the policy
sim.set_policy(NULL);
} }
catch(const CPUPolicyException& cpe)
{
// Fatal error. We should never get here.
std::cerr << _(" [EE] Fatal error. Impossible to deactivate the policy in ") << __FILE__ << ":" << __LINE__
<< std::endl << _(" [EE] ") << cpe.what() << std::endl;
;
abort();
}
}
catch(const NullPolicyException& npe)
{
MessageDialog diag(_("<b>No active policy selected:</b>\n") + Markup::escape_text(npe.what()),
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
diag.run();
}
catch(const CPUPolicyException& cpe)
{
MessageDialog diag(_("<b>Unexpected error</b>:\n") + Markup::escape_text(cpe.what()),
true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
diag.run();
}
h.set_notify_enabled(reenable); h.set_notify_enabled(reenable);
sim.detach(*this); sim.detach(*this);