QuickForm: catch Exceptions from success handlers

This commit is contained in:
Thomas Gelf 2015-10-15 17:52:56 +02:00
parent 0544be3aec
commit 7693192e66

View File

@ -8,6 +8,7 @@ use Icinga\Exception\ProgrammingError;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Web\Request; use Icinga\Web\Request;
use Icinga\Web\Url; use Icinga\Web\Url;
use Exception;
use Zend_Form; use Zend_Form;
/** /**
@ -300,7 +301,12 @@ abstract class QuickForm extends Zend_Form
if ($this->hasBeenSubmitted()) { if ($this->hasBeenSubmitted()) {
$this->beforeValidation($post); $this->beforeValidation($post);
if ($this->isValid($post)) { if ($this->isValid($post)) {
$this->onSuccess(); try {
$this->onSuccess();
} catch (Exception $e) {
$this->addError($e->getMessage());
$this->onFailure();
}
} else { } else {
$this->onFailure(); $this->onFailure();
} }