From 103578448db0ce03ea231a10e8234b2d8cb27e34 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Tue, 20 Jan 2015 19:23:42 +0100 Subject: One class per file: framework/Exceptions/ --- framework/Exceptions/TApplicationException.php | 23 ++ framework/Exceptions/TConfigurationException.php | 24 ++ framework/Exceptions/TDbConnectionException.php | 23 ++ framework/Exceptions/TDbException.php | 23 ++ framework/Exceptions/TException.php | 286 +-------------------- framework/Exceptions/THttpException.php | 58 +++++ framework/Exceptions/TIOException.php | 23 ++ framework/Exceptions/TInvalidDataTypeException.php | 23 ++ .../Exceptions/TInvalidDataValueException.php | 23 ++ .../Exceptions/TInvalidOperationException.php | 23 ++ framework/Exceptions/TNotSupportedException.php | 23 ++ framework/Exceptions/TPhpErrorException.php | 50 ++++ framework/Exceptions/TSystemException.php | 23 ++ framework/Exceptions/TTemplateException.php | 74 ++++++ 14 files changed, 414 insertions(+), 285 deletions(-) create mode 100644 framework/Exceptions/TApplicationException.php create mode 100644 framework/Exceptions/TConfigurationException.php create mode 100644 framework/Exceptions/TDbConnectionException.php create mode 100644 framework/Exceptions/TDbException.php create mode 100644 framework/Exceptions/THttpException.php create mode 100644 framework/Exceptions/TIOException.php create mode 100644 framework/Exceptions/TInvalidDataTypeException.php create mode 100644 framework/Exceptions/TInvalidDataValueException.php create mode 100644 framework/Exceptions/TInvalidOperationException.php create mode 100644 framework/Exceptions/TNotSupportedException.php create mode 100644 framework/Exceptions/TPhpErrorException.php create mode 100644 framework/Exceptions/TSystemException.php create mode 100644 framework/Exceptions/TTemplateException.php (limited to 'framework') diff --git a/framework/Exceptions/TApplicationException.php b/framework/Exceptions/TApplicationException.php new file mode 100644 index 00000000..9de434e0 --- /dev/null +++ b/framework/Exceptions/TApplicationException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TApplicationException class + * + * TApplicationException is the base class for all user application-level exceptions. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TApplicationException extends TException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TConfigurationException.php b/framework/Exceptions/TConfigurationException.php new file mode 100644 index 00000000..e2506472 --- /dev/null +++ b/framework/Exceptions/TConfigurationException.php @@ -0,0 +1,24 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TConfigurationException class + * + * TConfigurationException represents an exception caused by invalid configurations, + * such as error in an application configuration file or control template file. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TConfigurationException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TDbConnectionException.php b/framework/Exceptions/TDbConnectionException.php new file mode 100644 index 00000000..c39c6d8a --- /dev/null +++ b/framework/Exceptions/TDbConnectionException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TDbConnectionException class + * + * TDbConnectionException represents an exception caused by DB connection failure. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TDbConnectionException extends TDbException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TDbException.php b/framework/Exceptions/TDbException.php new file mode 100644 index 00000000..fe1d24f4 --- /dev/null +++ b/framework/Exceptions/TDbException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TDbException class + * + * TDbException represents an exception related with DB operations. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TDbException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TException.php b/framework/Exceptions/TException.php index 24dbdb0f..80dd01f1 100644 --- a/framework/Exceptions/TException.php +++ b/framework/Exceptions/TException.php @@ -122,288 +122,4 @@ class TException extends Exception { $this->message=$message; } -} - -/** - * TSystemException class - * - * TSystemException is the base class for all framework-level exceptions. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TSystemException extends TException -{ -} - -/** - * TApplicationException class - * - * TApplicationException is the base class for all user application-level exceptions. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TApplicationException extends TException -{ -} - -/** - * TInvalidOperationException class - * - * TInvalidOperationException represents an exception caused by invalid operations. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TInvalidOperationException extends TSystemException -{ -} - -/** - * TInvalidDataTypeException class - * - * TInvalidDataTypeException represents an exception caused by invalid data type. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TInvalidDataTypeException extends TSystemException -{ -} - -/** - * TInvalidDataValueException class - * - * TInvalidDataValueException represents an exception caused by invalid data value. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TInvalidDataValueException extends TSystemException -{ -} - -/** - * TConfigurationException class - * - * TConfigurationException represents an exception caused by invalid configurations, - * such as error in an application configuration file or control template file. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TConfigurationException extends TSystemException -{ -} - -/** - * TTemplateException class - * - * TTemplateException represents an exception caused by invalid template syntax. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.1 - */ -class TTemplateException extends TConfigurationException -{ - private $_template=''; - private $_lineNumber=0; - private $_fileName=''; - - /** - * @return string the template source code that causes the exception. This is empty if {@link getTemplateFile TemplateFile} is not empty. - */ - public function getTemplateSource() - { - return $this->_template; - } - - /** - * @param string the template source code that causes the exception - */ - public function setTemplateSource($value) - { - $this->_template=$value; - } - - /** - * @return string the template file that causes the exception. This could be empty if the template is an embedded template. In this case, use {@link getTemplateSource TemplateSource} to obtain the actual template content. - */ - public function getTemplateFile() - { - return $this->_fileName; - } - - /** - * @param string the template file that causes the exception - */ - public function setTemplateFile($value) - { - $this->_fileName=$value; - } - - /** - * @return integer the line number at which the template has error - */ - public function getLineNumber() - { - return $this->_lineNumber; - } - - /** - * @param integer the line number at which the template has error - */ - public function setLineNumber($value) - { - $this->_lineNumber=TPropertyValue::ensureInteger($value); - } -} - -/** - * TIOException class - * - * TIOException represents an exception related with improper IO operations. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TIOException extends TSystemException -{ -} - -/** - * TDbException class - * - * TDbException represents an exception related with DB operations. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TDbException extends TSystemException -{ -} - -/** - * TDbConnectionException class - * - * TDbConnectionException represents an exception caused by DB connection failure. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TDbConnectionException extends TDbException -{ -} - -/** - * TNotSupportedException class - * - * TNotSupportedException represents an exception caused by using an unsupported PRADO feature. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TNotSupportedException extends TSystemException -{ -} - -/** - * TPhpErrorException class - * - * TPhpErrorException represents an exception caused by a PHP error. - * This exception is mainly thrown within a PHP error handler. - * - * @author Qiang Xue - * @package System.Exceptions - * @since 3.0 - */ -class TPhpErrorException extends TSystemException -{ - /** - * Constructor. - * @param integer error number - * @param string error string - * @param string error file - * @param integer error line number - */ - public function __construct($errno,$errstr,$errfile,$errline) - { - static $errorTypes=array( - E_ERROR => "Error", - E_WARNING => "Warning", - E_PARSE => "Parsing Error", - E_NOTICE => "Notice", - E_CORE_ERROR => "Core Error", - E_CORE_WARNING => "Core Warning", - E_COMPILE_ERROR => "Compile Error", - E_COMPILE_WARNING => "Compile Warning", - E_USER_ERROR => "User Error", - E_USER_WARNING => "User Warning", - E_USER_NOTICE => "User Notice", - E_STRICT => "Runtime Notice" - ); - $errorType=isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; - parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); - } -} - - -/** - * 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 - * @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 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 @@ + + * @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 + * @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 diff --git a/framework/Exceptions/TIOException.php b/framework/Exceptions/TIOException.php new file mode 100644 index 00000000..42231284 --- /dev/null +++ b/framework/Exceptions/TIOException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TIOException class + * + * TIOException represents an exception related with improper IO operations. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TIOException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TInvalidDataTypeException.php b/framework/Exceptions/TInvalidDataTypeException.php new file mode 100644 index 00000000..03f94985 --- /dev/null +++ b/framework/Exceptions/TInvalidDataTypeException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TInvalidDataTypeException class + * + * TInvalidDataTypeException represents an exception caused by invalid data type. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TInvalidDataTypeException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TInvalidDataValueException.php b/framework/Exceptions/TInvalidDataValueException.php new file mode 100644 index 00000000..075bb871 --- /dev/null +++ b/framework/Exceptions/TInvalidDataValueException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TInvalidDataValueException class + * + * TInvalidDataValueException represents an exception caused by invalid data value. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TInvalidDataValueException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TInvalidOperationException.php b/framework/Exceptions/TInvalidOperationException.php new file mode 100644 index 00000000..4366e5f0 --- /dev/null +++ b/framework/Exceptions/TInvalidOperationException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TInvalidOperationException class + * + * TInvalidOperationException represents an exception caused by invalid operations. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TInvalidOperationException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TNotSupportedException.php b/framework/Exceptions/TNotSupportedException.php new file mode 100644 index 00000000..b793dbbe --- /dev/null +++ b/framework/Exceptions/TNotSupportedException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TNotSupportedException class + * + * TNotSupportedException represents an exception caused by using an unsupported PRADO feature. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TNotSupportedException extends TSystemException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TPhpErrorException.php b/framework/Exceptions/TPhpErrorException.php new file mode 100644 index 00000000..75218c44 --- /dev/null +++ b/framework/Exceptions/TPhpErrorException.php @@ -0,0 +1,50 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TPhpErrorException class + * + * TPhpErrorException represents an exception caused by a PHP error. + * This exception is mainly thrown within a PHP error handler. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TPhpErrorException extends TSystemException +{ + /** + * Constructor. + * @param integer error number + * @param string error string + * @param string error file + * @param integer error line number + */ + public function __construct($errno,$errstr,$errfile,$errline) + { + static $errorTypes=array( + E_ERROR => "Error", + E_WARNING => "Warning", + E_PARSE => "Parsing Error", + E_NOTICE => "Notice", + E_CORE_ERROR => "Core Error", + E_CORE_WARNING => "Core Warning", + E_COMPILE_ERROR => "Compile Error", + E_COMPILE_WARNING => "Compile Warning", + E_USER_ERROR => "User Error", + E_USER_WARNING => "User Warning", + E_USER_NOTICE => "User Notice", + E_STRICT => "Runtime Notice" + ); + $errorType=isset($errorTypes[$errno])?$errorTypes[$errno]:'Unknown Error'; + parent::__construct("[$errorType] $errstr (@line $errline in file $errfile)."); + } +} \ No newline at end of file diff --git a/framework/Exceptions/TSystemException.php b/framework/Exceptions/TSystemException.php new file mode 100644 index 00000000..5d5c7d8e --- /dev/null +++ b/framework/Exceptions/TSystemException.php @@ -0,0 +1,23 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TSystemException class + * + * TSystemException is the base class for all framework-level exceptions. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.0 + */ +class TSystemException extends TException +{ +} \ No newline at end of file diff --git a/framework/Exceptions/TTemplateException.php b/framework/Exceptions/TTemplateException.php new file mode 100644 index 00000000..7deb6ed0 --- /dev/null +++ b/framework/Exceptions/TTemplateException.php @@ -0,0 +1,74 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2014 PradoSoft + * @license http://www.pradosoft.com/license/ + * @package System.Exceptions + */ + +/** + * TTemplateException class + * + * TTemplateException represents an exception caused by invalid template syntax. + * + * @author Qiang Xue + * @package System.Exceptions + * @since 3.1 + */ +class TTemplateException extends TConfigurationException +{ + private $_template=''; + private $_lineNumber=0; + private $_fileName=''; + + /** + * @return string the template source code that causes the exception. This is empty if {@link getTemplateFile TemplateFile} is not empty. + */ + public function getTemplateSource() + { + return $this->_template; + } + + /** + * @param string the template source code that causes the exception + */ + public function setTemplateSource($value) + { + $this->_template=$value; + } + + /** + * @return string the template file that causes the exception. This could be empty if the template is an embedded template. In this case, use {@link getTemplateSource TemplateSource} to obtain the actual template content. + */ + public function getTemplateFile() + { + return $this->_fileName; + } + + /** + * @param string the template file that causes the exception + */ + public function setTemplateFile($value) + { + $this->_fileName=$value; + } + + /** + * @return integer the line number at which the template has error + */ + public function getLineNumber() + { + return $this->_lineNumber; + } + + /** + * @param integer the line number at which the template has error + */ + public function setLineNumber($value) + { + $this->_lineNumber=TPropertyValue::ensureInteger($value); + } +} \ No newline at end of file -- cgit v1.2.3