partially revert last change: stick to printf, but still allow

variable number of arguments in error handlers

we don't want to switch to strtr as ->raise() is used everywhere
without arrays...
This commit is contained in:
Antoine Beaupré 2008-04-24 18:17:43 +00:00
parent fc9c612c21
commit a843e1200d
1 changed files with 6 additions and 3 deletions

View File

@ -66,7 +66,8 @@ class m_err {
if (_("err_".$clsid."_".$error)!="err_".$clsid."_".$error || is_string($error)) { if (_("err_".$clsid."_".$error)!="err_".$clsid."_".$error || is_string($error)) {
$this->clsid=$clsid; $this->clsid=$clsid;
$this->error=$error; $this->error=$error;
$this->param=$param; $args = func_get_args();
$this->param=array_slice($args, 2);
$this->logerr(); $this->logerr();
return true; return true;
} else { } else {
@ -90,10 +91,12 @@ class m_err {
*/ */
function errstr() { function errstr() {
if (is_string($this->error)) { if (is_string($this->error)) {
$msg = strtr(_("err_".$this->clsid."_generic: ")._($this->error)."\n",$this->param); $str = _("err_".$this->clsid."_generic: ")._($this->error)."\n";
} else { } else {
$msg = strtr(_("err_".$this->clsid."_".$this->error)."\n",$this->param); $str = _("err_".$this->clsid."_".$this->error)."\n";
} }
$args = array_unshift($this->param, $str);
$msg = call_user_func_array("sprintf", $args);
return $msg; return $msg;
} }