Objects, FormLoader: exceptions, exceptions

This commit is contained in:
Thomas Gelf 2018-06-14 14:08:04 +02:00
parent 5be3f092a9
commit 9069a7f916
2 changed files with 11 additions and 4 deletions

View File

@ -213,8 +213,8 @@ abstract class ObjectsController extends ActionController
/**
* @throws \Icinga\Exception\ConfigurationError
* @throws \Icinga\Exception\Http\HttpNotFoundException
* @throws \Icinga\Exception\ProgrammingError
* @throws \Icinga\Security\SecurityException
* @throws NotFoundError
*/
public function applyrulesAction()
{
@ -256,6 +256,7 @@ abstract class ObjectsController extends ActionController
* @throws NotFoundError
* @throws \Icinga\Exception\ConfigurationError
* @throws \Icinga\Exception\Http\HttpNotFoundException
* @throws \Icinga\Security\SecurityException
*/
public function setsAction()
{
@ -325,7 +326,6 @@ abstract class ObjectsController extends ActionController
* @param string $name
*
* @return \Icinga\Module\Director\Web\Form\QuickForm
* @throws \Icinga\Exception\ProgrammingError
*/
public function loadForm($name)
{
@ -342,6 +342,7 @@ abstract class ObjectsController extends ActionController
* @param ZfQueryBasedTable $table
* @return ZfQueryBasedTable
* @throws \Icinga\Exception\ConfigurationError
* @throws NotFoundError
*/
protected function eventuallyFilterCommand(ZfQueryBasedTable $table)
{

View File

@ -5,13 +5,18 @@ namespace Icinga\Module\Director\Web\Form;
use Icinga\Application\Icinga;
use Icinga\Application\Modules\Module;
use Icinga\Exception\ProgrammingError;
use RuntimeException;
class FormLoader
{
public static function load($name, Module $module = null)
{
if ($module === null) {
$basedir = Icinga::app()->getApplicationDir('forms');
try {
$basedir = Icinga::app()->getApplicationDir('forms');
} catch (ProgrammingError $e) {
throw new RuntimeException($e->getMessage(), 0, $e);
}
$ns = '\\Icinga\\Web\\Forms\\';
} else {
$basedir = $module->getFormDir();
@ -32,6 +37,7 @@ class FormLoader
return new $class($options);
}
}
throw new ProgrammingError(sprintf('Cannot load %s (%s), no such form', $name, $file));
throw new RuntimeException(sprintf('Cannot load %s (%s), no such form', $name, $file));
}
}