protected function handleException(ActionEvent $actionEvent, \Exception $ex)
{
$failedPhase = $actionEvent->getName();
$actionEvent->setParam(self::EVENT_PARAM_EXCEPTION, $ex);
$this->triggerError($actionEvent);
$this->triggerFinalize($actionEvent);
//Check if a listener has removed the exception to indicate that it was able to handle it
if ($ex = $actionEvent->getParam(self::EVENT_PARAM_EXCEPTION)) {
$actionEvent->setName($failedPhase);
throw MessageDispatchException::failed($actionEvent, $ex);
}
}