123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624 |
- <?php
- /**
- * Exceptions file. Contains the various exceptions CakePHP will throw until they are
- * moved into their permanent location.
- *
- * PHP 5
- *
- * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
- * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
- *
- * Licensed under The MIT License
- * Redistributions of files must retain the above copyright notice.
- *
- * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
- * @link http://book.cakephp.org/2.0/en/development/testing.html
- * @package Cake.Error
- * @since CakePHP(tm) v 2.0
- * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
- */
- /**
- * Base class that all Exceptions extend.
- *
- * @package Cake.Error
- */
- class CakeBaseException extends RuntimeException {
- /**
- * Array of headers to be passed to CakeResponse::header()
- *
- * @var array
- */
- protected $_responseHeaders = null;
- /**
- * Get/set the response header to be used
- *
- * See also CakeResponse::header()
- *
- * @param string|array $header. An array of header strings or a single header string
- * - an associative array of "header name" => "header value"
- * - an array of string headers is also accepted
- * @param string $value. The header value.
- * @return array
- */
- public function responseHeader($header = null, $value = null) {
- if ($header) {
- if (is_array($header)) {
- return $this->_responseHeaders = $header;
- }
- $this->_responseHeaders = array($header => $value);
- }
- return $this->_responseHeaders;
- }
- }
- /**
- * Parent class for all of the HTTP related exceptions in CakePHP.
- * All HTTP status/error related exceptions should extend this class so
- * catch blocks can be specifically typed.
- *
- * @package Cake.Error
- */
- if (!class_exists('HttpException')) {
- class HttpException extends CakeBaseException {
- }
- }
- /**
- * Represents an HTTP 400 error.
- *
- * @package Cake.Error
- */
- class BadRequestException extends HttpException {
- /**
- * Constructor
- *
- * @param string $message If no message is given 'Bad Request' will be the message
- * @param string $code Status code, defaults to 400
- */
- public function __construct($message = null, $code = 400) {
- if (empty($message)) {
- $message = 'Bad Request';
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * Represents an HTTP 401 error.
- *
- * @package Cake.Error
- */
- class UnauthorizedException extends HttpException {
- /**
- * Constructor
- *
- * @param string $message If no message is given 'Unauthorized' will be the message
- * @param string $code Status code, defaults to 401
- */
- public function __construct($message = null, $code = 401) {
- if (empty($message)) {
- $message = 'Unauthorized';
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * Represents an HTTP 403 error.
- *
- * @package Cake.Error
- */
- class ForbiddenException extends HttpException {
- /**
- * Constructor
- *
- * @param string $message If no message is given 'Forbidden' will be the message
- * @param string $code Status code, defaults to 403
- */
- public function __construct($message = null, $code = 403) {
- if (empty($message)) {
- $message = 'Forbidden';
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * Represents an HTTP 404 error.
- *
- * @package Cake.Error
- */
- class NotFoundException extends HttpException {
- /**
- * Constructor
- *
- * @param string $message If no message is given 'Not Found' will be the message
- * @param string $code Status code, defaults to 404
- */
- public function __construct($message = null, $code = 404) {
- if (empty($message)) {
- $message = 'Not Found';
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * Represents an HTTP 405 error.
- *
- * @package Cake.Error
- */
- class MethodNotAllowedException extends HttpException {
- /**
- * Constructor
- *
- * @param string $message If no message is given 'Method Not Allowed' will be the message
- * @param string $code Status code, defaults to 405
- */
- public function __construct($message = null, $code = 405) {
- if (empty($message)) {
- $message = 'Method Not Allowed';
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * Represents an HTTP 500 error.
- *
- * @package Cake.Error
- */
- class InternalErrorException extends HttpException {
- /**
- * Constructor
- *
- * @param string $message If no message is given 'Internal Server Error' will be the message
- * @param string $code Status code, defaults to 500
- */
- public function __construct($message = null, $code = 500) {
- if (empty($message)) {
- $message = 'Internal Server Error';
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * CakeException is used a base class for CakePHP's internal exceptions.
- * In general framework errors are interpreted as 500 code errors.
- *
- * @package Cake.Error
- */
- class CakeException extends CakeBaseException {
- /**
- * Array of attributes that are passed in from the constructor, and
- * made available in the view when a development error is displayed.
- *
- * @var array
- */
- protected $_attributes = array();
- /**
- * Template string that has attributes sprintf()'ed into it.
- *
- * @var string
- */
- protected $_messageTemplate = '';
- /**
- * Constructor.
- *
- * Allows you to create exceptions that are treated as framework errors and disabled
- * when debug = 0.
- *
- * @param string|array $message Either the string of the error message, or an array of attributes
- * that are made available in the view, and sprintf()'d into CakeException::$_messageTemplate
- * @param string $code The code of the error, is also the HTTP status code for the error.
- */
- public function __construct($message, $code = 500) {
- if (is_array($message)) {
- $this->_attributes = $message;
- $message = __d('cake_dev', $this->_messageTemplate, $message);
- }
- parent::__construct($message, $code);
- }
- /**
- * Get the passed in attributes
- *
- * @return array
- */
- public function getAttributes() {
- return $this->_attributes;
- }
- }
- /**
- * Missing Controller exception - used when a controller
- * cannot be found.
- *
- * @package Cake.Error
- */
- class MissingControllerException extends CakeException {
- protected $_messageTemplate = 'Controller class %s could not be found.';
- //@codingStandardsIgnoreStart
- public function __construct($message, $code = 404) {
- parent::__construct($message, $code);
- }
- //@codingStandardsIgnoreEnd
- }
- /**
- * Missing Action exception - used when a controller action
- * cannot be found.
- *
- * @package Cake.Error
- */
- class MissingActionException extends CakeException {
- protected $_messageTemplate = 'Action %s::%s() could not be found.';
- //@codingStandardsIgnoreStart
- public function __construct($message, $code = 404) {
- parent::__construct($message, $code);
- }
- //@codingStandardsIgnoreEnd
- }
- /**
- * Private Action exception - used when a controller action
- * starts with a `_`.
- *
- * @package Cake.Error
- */
- class PrivateActionException extends CakeException {
- protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
- //@codingStandardsIgnoreStart
- public function __construct($message, $code = 404, Exception $previous = null) {
- parent::__construct($message, $code, $previous);
- }
- //@codingStandardsIgnoreEnd
- }
- /**
- * Used when a component cannot be found.
- *
- * @package Cake.Error
- */
- class MissingComponentException extends CakeException {
- protected $_messageTemplate = 'Component class %s could not be found.';
- }
- /**
- * Used when a behavior cannot be found.
- *
- * @package Cake.Error
- */
- class MissingBehaviorException extends CakeException {
- protected $_messageTemplate = 'Behavior class %s could not be found.';
- }
- /**
- * Used when a view file cannot be found.
- *
- * @package Cake.Error
- */
- class MissingViewException extends CakeException {
- protected $_messageTemplate = 'View file "%s" is missing.';
- }
- /**
- * Used when a layout file cannot be found.
- *
- * @package Cake.Error
- */
- class MissingLayoutException extends CakeException {
- protected $_messageTemplate = 'Layout file "%s" is missing.';
- }
- /**
- * Used when a helper cannot be found.
- *
- * @package Cake.Error
- */
- class MissingHelperException extends CakeException {
- protected $_messageTemplate = 'Helper class %s could not be found.';
- }
- /**
- * Runtime Exceptions for ConnectionManager
- *
- * @package Cake.Error
- */
- class MissingDatabaseException extends CakeException {
- protected $_messageTemplate = 'Database connection "%s" could not be found.';
- }
- /**
- * Used when no connections can be found.
- *
- * @package Cake.Error
- */
- class MissingConnectionException extends CakeException {
- protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
- public function __construct($message, $code = 500) {
- if (is_array($message)) {
- $message += array('enabled' => true);
- }
- parent::__construct($message, $code);
- }
- }
- /**
- * Used when a Task cannot be found.
- *
- * @package Cake.Error
- */
- class MissingTaskException extends CakeException {
- protected $_messageTemplate = 'Task class %s could not be found.';
- }
- /**
- * Used when a shell method cannot be found.
- *
- * @package Cake.Error
- */
- class MissingShellMethodException extends CakeException {
- protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
- }
- /**
- * Used when a shell cannot be found.
- *
- * @package Cake.Error
- */
- class MissingShellException extends CakeException {
- protected $_messageTemplate = 'Shell class %s could not be found.';
- }
- /**
- * Exception class to be thrown when a datasource configuration is not found
- *
- * @package Cake.Error
- */
- class MissingDatasourceConfigException extends CakeException {
- protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
- }
- /**
- * Used when a datasource cannot be found.
- *
- * @package Cake.Error
- */
- class MissingDatasourceException extends CakeException {
- protected $_messageTemplate = 'Datasource class %s could not be found.';
- }
- /**
- * Exception class to be thrown when a database table is not found in the datasource
- *
- * @package Cake.Error
- */
- class MissingTableException extends CakeException {
- protected $_messageTemplate = 'Table %s for model %s was not found in datasource %s.';
- }
- /**
- * Exception raised when a Model could not be found.
- *
- * @package Cake.Error
- */
- class MissingModelException extends CakeException {
- protected $_messageTemplate = 'Model %s could not be found.';
- }
- /**
- * Exception raised when a test loader could not be found
- *
- * @package Cake.Error
- */
- class MissingTestLoaderException extends CakeException {
- protected $_messageTemplate = 'Test loader %s could not be found.';
- }
- /**
- * Exception raised when a plugin could not be found
- *
- * @package Cake.Error
- */
- class MissingPluginException extends CakeException {
- protected $_messageTemplate = 'Plugin %s could not be found.';
- }
- /**
- * Exception raised when a Dispatcher filter could not be found
- *
- * @package Cake.Error
- */
- class MissingDispatcherFilterException extends CakeException {
- protected $_messageTemplate = 'Dispatcher filter %s could not be found.';
- }
- /**
- * Exception class for AclComponent and Interface implementations.
- *
- * @package Cake.Error
- */
- class AclException extends CakeException {
- }
- /**
- * Exception class for Cache. This exception will be thrown from Cache when it
- * encounters an error.
- *
- * @package Cake.Error
- */
- class CacheException extends CakeException {
- }
- /**
- * Exception class for Router. This exception will be thrown from Router when it
- * encounters an error.
- *
- * @package Cake.Error
- */
- class RouterException extends CakeException {
- }
- /**
- * Exception class for CakeLog. This exception will be thrown from CakeLog when it
- * encounters an error.
- *
- * @package Cake.Error
- */
- class CakeLogException extends CakeException {
- }
- /**
- * Exception class for CakeSession. This exception will be thrown from CakeSession when it
- * encounters an error.
- *
- * @package Cake.Error
- */
- class CakeSessionException extends CakeException {
- }
- /**
- * Exception class for Configure. This exception will be thrown from Configure when it
- * encounters an error.
- *
- * @package Cake.Error
- */
- class ConfigureException extends CakeException {
- }
- /**
- * Exception class for Socket. This exception will be thrown from CakeSocket, CakeEmail, HttpSocket
- * SmtpTransport, MailTransport and HttpResponse when it encounters an error.
- *
- * @package Cake.Error
- */
- class SocketException extends CakeException {
- }
- /**
- * Exception class for Xml. This exception will be thrown from Xml when it
- * encounters an error.
- *
- * @package Cake.Error
- */
- class XmlException extends CakeException {
- }
- /**
- * Exception class for Console libraries. This exception will be thrown from Console library
- * classes when they encounter an error.
- *
- * @package Cake.Error
- */
- class ConsoleException extends CakeException {
- }
- /**
- * Represents a fatal error
- *
- * @package Cake.Error
- */
- class FatalErrorException extends CakeException {
- /**
- * Constructor
- *
- * @param string $message
- * @param integer $code
- * @param string $file
- * @param integer $line
- */
- public function __construct($message, $code = 500, $file = null, $line = null) {
- parent::__construct($message, $code);
- if ($file) {
- $this->file = $file;
- }
- if ($line) {
- $this->line = $line;
- }
- }
- }
- /**
- * Not Implemented Exception - used when an API method is not implemented
- *
- * @package Cake.Error
- */
- class NotImplementedException extends CakeException {
- protected $_messageTemplate = '%s is not implemented.';
- //@codingStandardsIgnoreStart
- public function __construct($message, $code = 501) {
- parent::__construct($message, $code);
- }
- //@codingStandardsIgnoreEnd
- }
|