Commit 2e75fb09 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(management) Show an error message if an action call is invalid

issue #5927
parent 48f1b0e9
......@@ -153,10 +153,10 @@ class Action
return;
}
if (count($action['targets']) < $this->minTargets) {
throw new FusionDirectoryException('Not enough targets ('.count($action['targets']).') passed for action '.$this->name);
throw new FusionDirectoryException(sprintf(_('Not enough targets (%d) passed for action "%s"'), count($action['targets']), $this->name));
}
if (($this->maxTargets !== FALSE) && (count($action['targets']) > $this->maxTargets)) {
throw new FusionDirectoryException('Too many targets ('.count($action['targets']).') passed for action '.$this->name);
throw new FusionDirectoryException(sprintf(_('Too many targets (%d) passed for action "%s"'), count($action['targets']), $this->name));
}
$func = $this->callable;
if (!is_array($func)) {
......
......@@ -420,9 +420,13 @@ class management
$action = $this->detectPostActions();
if (!empty($action['action'])) {
@DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $action, 'Action');
$str = $this->handleAction($action);
if ($str) {
return $this->getHeader().$str;
try {
$str = $this->handleAction($action);
if ($str) {
return $this->getHeader().$str;
}
} catch (FusionDirectoryException $e) {
msg_dialog::display(_('Error'), $e->getMessage(), ERROR_DIALOG);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment