Skip to content

Commit

Permalink
Exploded the exception files in multiple class files. Now it lazy loa…
Browse files Browse the repository at this point in the history
…d the classes
  • Loading branch information
jrbasso committed Jun 24, 2012
1 parent a17a4af commit 2739974
Show file tree
Hide file tree
Showing 42 changed files with 1,294 additions and 575 deletions.
27 changes: 27 additions & 0 deletions lib/Cake/Error/AclException.php
@@ -0,0 +1,27 @@
<?php
/**
* AclException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* Exception class for AclComponent and Interface implementations.
*
* @package Cake.Error
*/
class AclException extends Exception {
}
41 changes: 41 additions & 0 deletions lib/Cake/Error/BadRequestException.php
@@ -0,0 +1,41 @@
<?php
/**
* BadRequestException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* 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);
}

}
28 changes: 28 additions & 0 deletions lib/Cake/Error/CacheException.php
@@ -0,0 +1,28 @@
<?php
/**
* CacheException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* Exception class for Cache. This exception will be thrown from Cache when it
* encounters an error.
*
* @package Cake.Error
*/
class CacheException extends Exception {
}
28 changes: 28 additions & 0 deletions lib/Cake/Error/ConfigureException.php
@@ -0,0 +1,28 @@
<?php
/**
* ConfigureException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* Exception class for Configure. This exception will be thrown from Configure when it
* encounters an error.
*
* @package Cake.Error
*/
class ConfigureException extends Exception {
}
28 changes: 28 additions & 0 deletions lib/Cake/Error/ConsoleException.php
@@ -0,0 +1,28 @@
<?php
/**
* ConsoleException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* 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 Exception {
}
71 changes: 71 additions & 0 deletions lib/Cake/Error/Exception.php
@@ -0,0 +1,71 @@
<?php
/**
* Exception class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* Exception is used a base class for CakePHP's internal exceptions.
* In general framework errors are interpreted as 500 code errors.
*
* @package Cake.Error
*/
class Exception extends \RuntimeException {

/**
* 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 Exception::$_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;
}

}
46 changes: 46 additions & 0 deletions lib/Cake/Error/FatalErrorException.php
@@ -0,0 +1,46 @@
<?php
/**
* FatalErrorException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* Represents a fatal error
*
* @package Cake.Error
*/
class FatalErrorException extends Exception {

/**
* 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;
}
}

}
41 changes: 41 additions & 0 deletions lib/Cake/Error/ForbiddenException.php
@@ -0,0 +1,41 @@
<?php
/**
* ForbiddenException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* 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);
}

}
29 changes: 29 additions & 0 deletions lib/Cake/Error/HttpException.php
@@ -0,0 +1,29 @@
<?php
/**
* HttpException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* 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
*/
class HttpException extends \RuntimeException {
}
41 changes: 41 additions & 0 deletions lib/Cake/Error/InternalErrorException.php
@@ -0,0 +1,41 @@
<?php
/**
* InternalErrorException class
*
* 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 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace Cake\Error;

/**
* 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);
}

}

0 comments on commit 2739974

Please sign in to comment.