- All policy-related errors should now be handled. I hope this is the last time I say this...
git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@850 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
cb4f0e878d
commit
1be6a9ca58
7 changed files with 102 additions and 36 deletions
|
@ -155,11 +155,39 @@ ConcreteSimulation::get_history()
|
|||
}
|
||||
|
||||
void
|
||||
ConcreteSimulation::set_policy(CPUPolicy* p)
|
||||
ConcreteSimulation::set_policy(CPUPolicy* p) throw(CPUPolicyException)
|
||||
{
|
||||
_policy = p;
|
||||
// NOTE: restoring of the previous policy is done here because I
|
||||
// couldn't think of a clean way to do it
|
||||
// inside activate_policy()
|
||||
|
||||
try
|
||||
{
|
||||
CPUPoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
||||
_policy = p;
|
||||
}
|
||||
catch(const CPUPolicyException& e1)
|
||||
{
|
||||
try
|
||||
{
|
||||
// this is a no-op if _policy is NULL
|
||||
CPUPoliciesGatekeeper::get_instance().activate_policy(&_history, _policy);
|
||||
}
|
||||
catch(const CPUPolicyException& e2)
|
||||
{
|
||||
_policy = NULL;
|
||||
|
||||
CPUPoliciesGatekeeper::get_instance().activate_policy(&_history, p);
|
||||
string msg = _("unable to change policy and to restore the previous: ");
|
||||
msg += e2.what();
|
||||
|
||||
throw CPUPolicyException(msg);
|
||||
}
|
||||
|
||||
string msg = _("unable to change policy: ");
|
||||
msg+= e1.what();
|
||||
|
||||
throw CPUPolicyException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue