summaryrefslogtreecommitdiff
path: root/framework/Exceptions/TException.php
diff options
context:
space:
mode:
authorxue <>2006-02-27 02:45:59 +0000
committerxue <>2006-02-27 02:45:59 +0000
commit7956ad5e7ed68e4d35ee021986830fe06a7b071e (patch)
tree27708da400de367685a9e57e1335614bf491fbce /framework/Exceptions/TException.php
parentf6a0691f3cd3ae16dee61b86d0fcfea27a3f751b (diff)
Changed the way of passing parameters to exception messages.
Diffstat (limited to 'framework/Exceptions/TException.php')
-rw-r--r--framework/Exceptions/TException.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/framework/Exceptions/TException.php b/framework/Exceptions/TException.php
index 60b47193..8ace1535 100644
--- a/framework/Exceptions/TException.php
+++ b/framework/Exceptions/TException.php
@@ -38,13 +38,24 @@ class TException extends Exception
{
private $_errorCode='';
+ /**
+ * Constructor.
+ * @param string error message. This can be a string that is listed
+ * in the message file. If so, the message in the preferred language
+ * will be used as the error message. Any rest parameters will be used
+ * to replace placeholders ({0}, {1}, {2}, etc.) in the message.
+ */
public function __construct($errorMessage)
{
$this->_errorCode=$errorMessage;
+ $errorMessage=$this->translateErrorMessage($errorMessage);
$args=func_get_args();
- $args[0]=$this->translateErrorMessage($errorMessage);
- $str=call_user_func_array('sprintf',$args);
- parent::__construct($str);
+ array_shift($args);
+ $n=count($args);
+ $tokens=array();
+ for($i=0;$i<$n;++$i)
+ $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]);
+ parent::__construct(strtr($errorMessage,$tokens));
}
protected function translateErrorMessage($key)
@@ -164,11 +175,15 @@ class THttpException extends TSystemException
{
$this->_statusCode=$statusCode;
$this->setErrorCode($errorMessage);
+ $errorMessage=$this->translateErrorMessage($errorMessage);
$args=func_get_args();
array_shift($args);
- $args[0]=$this->translateErrorMessage($errorMessage);
- $str=call_user_func_array('sprintf',$args);
- $this->setErrorMessage($str);
+ array_shift($args);
+ $n=count($args);
+ $tokens=array();
+ for($i=0;$i<$n;++$i)
+ $tokens['{'.$i.'}']=TPropertyValue::ensureString($args[$i]);
+ parent::__construct(strtr($errorMessage,$tokens));
}
public function getStatusCode()