FIX Error not reported by batch

This commit is contained in:
Laurent Destailleur 2018-04-20 09:46:02 +02:00
parent 5794e38c54
commit 7d3d4e6c89

View File

@ -1068,9 +1068,16 @@ class Cronjob extends CommonObject
if ($result === false || (! is_bool($result) && $result != 0))
{
$langs->load("errors");
dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$object->error, LOG_ERR);
$this->error = $object->error?$object->error:$langs->trans('ErrorUnknown');
$this->lastoutput = ($object->output?$object->output."\n":"").$this->error;
$errmsg='';
if (! is_array($object->errors) || ! in_array($object->error, $object->errors)) $errmsg.=$object->error;
if (is_array($object->errors) && count($object->errors)) $errmsg.=($errmsg?', '.$errmsg:'').join(', ',$object->errors);
if (empty($errmsg)) $errmsg=$langs->trans('ErrorUnknown');
dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$errmsg, LOG_ERR);
$this->error = $errmsg;
$this->lastoutput = ($object->output?$object->output."\n":"").$errmsg;
$this->lastresult = is_numeric($result)?$result:-1;
$retval = $this->lastresult;
$error++;