DirectorObjectForm: improve Exception error message

This commit is contained in:
Thomas Gelf 2016-10-05 18:03:07 +00:00
parent d1b7083145
commit 70b8a9ea02
1 changed files with 16 additions and 1 deletions

View File

@ -214,7 +214,22 @@ abstract class DirectorObjectForm extends QuickForm
}
} catch (Exception $e) {
$this->getElement($key)->addError($e->getMessage());
$file = preg_split('/[\/\\\]/', $e->getFile(), -1, PREG_SPLIT_NO_EMPTY);
$file = array_pop($file);
$msg = sprintf(
'%s (%s:%d)',
$e->getMessage(),
$file,
$e->getLine()
);
if ($el = $this->getElement($key)) {
// TODO: to be preferred $el->addError($e->getMessage());
$this->addError($msg);
} else {
$this->addError($msg);
}
}
}
}