avoid 500 if method is not defined

This commit is contained in:
fbsanchez 2019-10-02 18:43:27 +02:00
parent 79dca2fe6b
commit 2ec659baac
2 changed files with 7 additions and 3 deletions

View File

@ -20,7 +20,7 @@ if ($method) {
echo $viewer->{$method}(); echo $viewer->{$method}();
} }
} catch (Exception $e) { } catch (Exception $e) {
echo json_encode(['error' => $e->msg()]); echo json_encode(['error' => $e->getMessage()]);
return; return;
} }

View File

@ -45,7 +45,7 @@ class View extends \HTML
* *
* @return string HTML code for Form. * @return string HTML code for Form.
* *
* @throws Exception On error. * @throws \Exception On error.
*/ */
public function loadForm() public function loadForm()
{ {
@ -64,7 +64,11 @@ class View extends \HTML
$itemClass = VisualConsole::getItemClass($type); $itemClass = VisualConsole::getItemClass($type);
if (!isset($itemClass)) { if (!isset($itemClass)) {
throw new Exception(__('Item type not valid ['.$type.']')); throw new \Exception(__('Item type not valid ['.$type.']'));
}
if (\method_exists($itemClass, 'getFormInputs') === false) {
throw new \Exception(__('Item type has no getFormInputs method ['.$type.']'));
} }
$form = [ $form = [