Fix: Better error management
This commit is contained in:
parent
6963bfadcb
commit
65678132d5
@ -444,7 +444,13 @@ function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png" ){
|
|||||||
dol_syslog("php-barcode.php:barcode_print $code $encoding $scale $mode");
|
dol_syslog("php-barcode.php:barcode_print $code $encoding $scale $mode");
|
||||||
|
|
||||||
$bars=barcode_encode($code,$encoding);
|
$bars=barcode_encode($code,$encoding);
|
||||||
if (!$bars) return;
|
if (!$bars)
|
||||||
|
{
|
||||||
|
// DOLCHANGE LDR Return error message instead of array
|
||||||
|
$error='Bad Value '.$code.' for encoding '.$encoding;
|
||||||
|
dol_syslog('php-barcode.php:barcode_print '.$error, LOG_ERR);
|
||||||
|
return $error;
|
||||||
|
}
|
||||||
if (!$mode) $mode="png";
|
if (!$mode) $mode="png";
|
||||||
if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']);
|
if (preg_match("/^(text|txt|plain)$/i",$mode)) print barcode_outtext($bars['text'],$bars['bars']);
|
||||||
elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
|
elseif (preg_match("/^(html|htm)$/i",$mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
|
||||||
|
|||||||
@ -45,7 +45,7 @@ class modPhpbarcode extends ModeleBarCode
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** \brief Renvoi la description du modele de num<EFBFBD>rotation
|
/** \brief Return description
|
||||||
* \return string Texte descripif
|
* \return string Texte descripif
|
||||||
*/
|
*/
|
||||||
function info()
|
function info()
|
||||||
@ -111,7 +111,14 @@ class modPhpbarcode extends ModeleBarCode
|
|||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/php-barcode.php');
|
require_once(DOL_DOCUMENT_ROOT.'/includes/barcode/php-barcode/php-barcode.php');
|
||||||
dol_syslog("modPhpbarcode::buildBarCode $code,$encoding,$scale,$mode");
|
dol_syslog("modPhpbarcode::buildBarCode $code,$encoding,$scale,$mode");
|
||||||
if ($code) barcode_print($code,$encoding,$scale,$mode);
|
if ($code) $result=barcode_print($code,$encoding,$scale,$mode);
|
||||||
|
|
||||||
|
if (! is_array($result))
|
||||||
|
{
|
||||||
|
$this->error=$result;
|
||||||
|
print $this->error;exit;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user