diff options
author | Fabio Bas <ctrlaltca@gmail.com> | 2015-01-20 19:23:42 +0100 |
---|---|---|
committer | Fabio Bas <ctrlaltca@gmail.com> | 2015-01-20 19:23:42 +0100 |
commit | 103578448db0ce03ea231a10e8234b2d8cb27e34 (patch) | |
tree | d903ab3b16949fa3b75ec96718cf7c4547401932 /framework/Exceptions/THttpException.php | |
parent | 169950e09cad0e69a7dcbcdabe7ef86086766483 (diff) |
One class per file: framework/Exceptions/
Diffstat (limited to 'framework/Exceptions/THttpException.php')
-rw-r--r-- | framework/Exceptions/THttpException.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/framework/Exceptions/THttpException.php b/framework/Exceptions/THttpException.php new file mode 100644 index 00000000..f151138b --- /dev/null +++ b/framework/Exceptions/THttpException.php @@ -0,0 +1,58 @@ +<?php +/** + * Exception classes file + * + * @author Qiang Xue <qiang.xue@gmail.com> + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + + +/** + * THttpException class + * + * THttpException represents an exception that is caused by invalid operations + * of end-users. The {@link getStatusCode StatusCode} gives the type of HTTP error. + * It is used by {@link TErrorHandler} to provide different error output to users. + * + * @author Qiang Xue <qiang.xue@gmail.com> + * @package System.Exceptions + * @since 3.0 + */ +class THttpException extends TSystemException +{ + private $_statusCode; + + /** + * Constructor. + * @param integer HTTP status code, such as 404, 500, etc. + * @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($statusCode,$errorMessage) + { + $this->_statusCode=$statusCode; + $this->setErrorCode($errorMessage); + $errorMessage=$this->translateErrorMessage($errorMessage); + $args=func_get_args(); + array_shift($args); + 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)); + } + + /** + * @return integer HTTP status code, such as 404, 500, etc. + */ + public function getStatusCode() + { + return $this->_statusCode; + } +}
\ No newline at end of file |