Unverified Commit cc76507b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

:ambulance: fix(errors) Improve string conversion of errors

When errors get converted to strings in CSV import error dialog, it
 outputs the trace which is way too much text. Errors should convert to
 their error message, to look the same as before we used error objects.

issue #6071
parent be36cfac
No related merge requests found
Showing with 31 additions and 0 deletions
+31 -0
......@@ -45,6 +45,11 @@ class FusionDirectoryError extends Error
];
}
public function __toString ()
{
return $this->getMessage();
}
public function computeMsgDialogParameters (): array
{
return [_('Error'), $this->htmlMessage, ERROR_DIALOG, static::formatTrace($this)];
......
......@@ -76,6 +76,30 @@ class SimplePluginError extends FusionDirectoryError
return $array;
}
public function __toString ()
{
$msg = '';
if (isset($this->object)) {
$msg .= $this->object->getBaseObject()->dn.' > ';
}
if (isset($this->tab) && isset($this->tab->parent->by_name[get_class($this->tab)])) {
$msg .= $this->tab->parent->by_name[get_class($this->tab)].' > ';
}
if (isset($this->attribute)) {
$label = $this->attribute->getLabel();
if (empty($label)) {
$msg .= $this->attribute->getLdapName();
} else {
$msg .= $label;
}
}
return $msg.': '.$this->getMessage();
}
public function computeMsgDialogParameters (): array
{
$html = '';
......
......@@ -135,6 +135,8 @@ interface SimpleTab
/*!
* \brief Deserialize values
*
* Returns TRUE or error
*/
public function deserializeValues (array $values, bool $checkAcl = TRUE);
......
Supports Markdown
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