CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.0 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.0
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Auth
    • Core
    • Error
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • ErrorHandler
  • ExceptionRenderer

Exceptions

  • BadRequestException
  • CacheException
  • CakeException
  • CakeLogException
  • CakeSessionException
  • ConfigureException
  • ConsoleException
  • ForbiddenException
  • HttpException
  • InternalErrorException
  • MethodNotAllowedException
  • MissingActionException
  • MissingBehaviorException
  • MissingComponentException
  • MissingConnectionException
  • MissingControllerException
  • MissingDatabaseException
  • MissingDatasourceConfigException
  • MissingDatasourceException
  • MissingHelperException
  • MissingLayoutException
  • MissingModelException
  • MissingPluginException
  • MissingShellException
  • MissingShellMethodException
  • MissingTableException
  • MissingTaskException
  • MissingTestLoaderException
  • MissingViewException
  • NotFoundException
  • PrivateActionException
  • RouterException
  • SocketException
  • UnauthorizedException
  • XmlException
  1: <?php
  2: /**
  3:  * Exceptions file.  Contains the various exceptions CakePHP will throw until they are
  4:  * moved into their permanent location.
  5:  *
  6:  * PHP 5
  7:  *
  8:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  9:  * Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 10:  *
 11:  * Licensed under The MIT License
 12:  * Redistributions of files must retain the above copyright notice.
 13:  *
 14:  * @copyright     Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
 15:  * @link          http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
 16:  * @package       Cake.Error
 17:  * @since         CakePHP(tm) v 2.0
 18:  * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 19:  */
 20: 
 21: /**
 22:  * Parent class for all of the HTTP related exceptions in CakePHP.
 23:  * All HTTP status/error related exceptions should extend this class so
 24:  * catch blocks can be specifically typed.
 25:  *
 26:  * @package       Cake.Error
 27:  */
 28: if (!class_exists('HttpException')) {
 29:     class HttpException extends RuntimeException { }
 30: }
 31: 
 32: /**
 33:  * Represents an HTTP 400 error.
 34:  *
 35:  * @package       Cake.Error
 36:  */
 37: class BadRequestException extends HttpException {
 38: /**
 39:  * Constructor
 40:  *
 41:  * @param string $message If no message is given 'Bad Request' will be the message
 42:  * @param string $code Status code, defaults to 400
 43:  */
 44:     public function __construct($message = null, $code = 400) {
 45:         if (empty($message)) {
 46:             $message = 'Bad Request';
 47:         }
 48:         parent::__construct($message, $code);
 49:     }
 50: }
 51: 
 52: /**
 53:  * Represents an HTTP 401 error.
 54:  *
 55:  * @package       Cake.Error
 56:  */
 57: class UnauthorizedException extends HttpException {
 58: /**
 59:  * Constructor
 60:  *
 61:  * @param string $message If no message is given 'Unauthorized' will be the message
 62:  * @param string $code Status code, defaults to 401
 63:  */
 64:     public function __construct($message = null, $code = 401) {
 65:         if (empty($message)) {
 66:             $message = 'Unauthorized';
 67:         }
 68:         parent::__construct($message, $code);
 69:     }
 70: }
 71: 
 72: /**
 73:  * Represents an HTTP 403 error.
 74:  *
 75:  * @package       Cake.Error
 76:  */
 77: class ForbiddenException extends HttpException {
 78: /**
 79:  * Constructor
 80:  *
 81:  * @param string $message If no message is given 'Forbidden' will be the message
 82:  * @param string $code Status code, defaults to 403
 83:  */
 84:     public function __construct($message = null, $code = 403) {
 85:         if (empty($message)) {
 86:             $message = 'Forbidden';
 87:         }
 88:         parent::__construct($message, $code);
 89:     }
 90: }
 91: 
 92: /**
 93:  * Represents an HTTP 404 error.
 94:  *
 95:  * @package       Cake.Error
 96:  */
 97: class NotFoundException extends HttpException {
 98: /**
 99:  * Constructor
100:  *
101:  * @param string $message If no message is given 'Not Found' will be the message
102:  * @param string $code Status code, defaults to 404
103:  */
104:     public function __construct($message = null, $code = 404) {
105:         if (empty($message)) {
106:             $message = 'Not Found';
107:         }
108:         parent::__construct($message, $code);
109:     }
110: }
111: 
112: /**
113:  * Represents an HTTP 405 error.
114:  *
115:  * @package       Cake.Error
116:  */
117: class MethodNotAllowedException extends HttpException {
118: /**
119:  * Constructor
120:  *
121:  * @param string $message If no message is given 'Method Not Allowed' will be the message
122:  * @param string $code Status code, defaults to 405
123:  */
124:     public function __construct($message = null, $code = 405) {
125:         if (empty($message)) {
126:             $message = 'Method Not Allowed';
127:         }
128:         parent::__construct($message, $code);
129:     }
130: }
131: 
132: /**
133:  * Represents an HTTP 500 error.
134:  *
135:  * @package       Cake.Error
136:  */
137: class InternalErrorException extends HttpException {
138: /**
139:  * Constructor
140:  *
141:  * @param string $message If no message is given 'Internal Server Error' will be the message
142:  * @param string $code Status code, defaults to 500
143:  */
144:     public function __construct($message = null, $code = 500) {
145:         if (empty($message)) {
146:             $message = 'Internal Server Error';
147:         }
148:         parent::__construct($message, $code);
149:     }
150: }
151: 
152: /**
153:  * CakeException is used a base class for CakePHP's internal exceptions.
154:  * In general framework errors are interpreted as 500 code errors.
155:  *
156:  * @package       Cake.Error
157:  */
158: class CakeException extends RuntimeException {
159: /**
160:  * Array of attributes that are passed in from the constructor, and
161:  * made available in the view when a development error is displayed.
162:  *
163:  * @var array
164:  */
165:     protected $_attributes = array();
166: 
167: /**
168:  * Template string that has attributes sprintf()'ed into it.
169:  *
170:  * @var string
171:  */
172:     protected $_messageTemplate = '';
173: 
174: /**
175:  * Constructor.
176:  *
177:  * Allows you to create exceptions that are treated as framework errors and disabled
178:  * when debug = 0.
179:  *
180:  * @param mixed $message Either the string of the error message, or an array of attributes
181:  *   that are made available in the view, and sprintf()'d into CakeException::$_messageTemplate
182:  * @param string $code The code of the error, is also the HTTP status code for the error.
183:  */
184:     public function __construct($message, $code = 500) {
185:         if (is_array($message)) {
186:             $this->_attributes = $message;
187:             $message = __d('cake_dev', $this->_messageTemplate, $message);
188:         }
189:         parent::__construct($message, $code);
190:     }
191: 
192: /**
193:  * Get the passed in attributes
194:  *
195:  * @return array
196:  */
197:     public function getAttributes() {
198:         return $this->_attributes;
199:     }
200: }
201: 
202: /**
203:  * Missing Controller exception - used when a controller
204:  * cannot be found.
205:  *
206:  * @package       Cake.Error
207:  */
208: class MissingControllerException extends CakeException {
209:     protected $_messageTemplate = 'Controller class %s could not be found.';
210: 
211:     public function __construct($message, $code = 404) {
212:         parent::__construct($message, $code);
213:     }
214: }
215: 
216: /**
217:  * Missing Action exception - used when a controller action
218:  * cannot be found.
219:  *
220:  * @package       Cake.Error
221:  */
222: class MissingActionException extends CakeException {
223:     protected $_messageTemplate = 'Action %s::%s() could not be found.';
224: 
225:     public function __construct($message, $code = 404) {
226:         parent::__construct($message, $code);
227:     }
228: }
229: 
230: /**
231:  * Private Action exception - used when a controller action
232:  * starts with a  `_`.
233:  *
234:  * @package       Cake.Error
235:  */
236: class PrivateActionException extends CakeException {
237:     protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
238: 
239:     public function __construct($message, $code = 404, Exception $previous = null) {
240:         parent::__construct($message, $code, $previous);
241:     }
242: }
243: 
244: /**
245:  * Used when a component cannot be found.
246:  *
247:  * @package       Cake.Error
248:  */
249: class MissingComponentException extends CakeException {
250:     protected $_messageTemplate = 'Component class %s could not be found.';
251: }
252: 
253: /**
254:  * Used when a behavior cannot be found.
255:  *
256:  * @package       Cake.Error
257:  */
258: class MissingBehaviorException extends CakeException {
259:     protected $_messageTemplate = 'Behavior class %s could not be found.';
260: }
261: 
262: /**
263:  * Used when a view file cannot be found.
264:  *
265:  * @package       Cake.Error
266:  */
267: class MissingViewException extends CakeException {
268:     protected $_messageTemplate = 'View file "%s" is missing.';
269: }
270: 
271: /**
272:  * Used when a layout file cannot be found.
273:  *
274:  * @package       Cake.Error
275:  */
276: class MissingLayoutException extends CakeException {
277:     protected $_messageTemplate = 'Layout file "%s" is missing.';
278: }
279: 
280: /**
281:  * Used when a helper cannot be found.
282:  *
283:  * @package       Cake.Error
284:  */
285: class MissingHelperException extends CakeException {
286:     protected $_messageTemplate = 'Helper class %s could not be found.';
287: }
288: 
289: /**
290:  * Runtime Exceptions for ConnectionManager
291:  *
292:  * @package       Cake.Error
293:  */
294: class MissingDatabaseException extends CakeException {
295:     protected $_messageTemplate = 'Database connection "%s" could not be found.';
296: }
297: 
298: /**
299:  * Used when no connections can be found.
300:  *
301:  * @package       Cake.Error
302:  */
303: class MissingConnectionException extends CakeException {
304:     protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
305: }
306: 
307: /**
308:  * Used when a Task cannot be found.
309:  *
310:  * @package       Cake.Error
311:  */
312: class MissingTaskException extends CakeException {
313:     protected $_messageTemplate = 'Task class %s could not be found.';
314: }
315: 
316: /**
317:  * Used when a shell method cannot be found.
318:  *
319:  * @package       Cake.Error
320:  */
321: class MissingShellMethodException extends CakeException {
322:     protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
323: }
324: 
325: /**
326:  * Used when a shell cannot be found.
327:  *
328:  * @package       Cake.Error
329:  */
330: class MissingShellException extends CakeException {
331:     protected $_messageTemplate = 'Shell class %s could not be found.';
332: }
333: 
334: /**
335:  * Exception class to be thrown when a datasource configuration is not found
336:  *
337:  * @package       Cake.Error
338:  */
339: class MissingDatasourceConfigException extends CakeException {
340:     protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
341: }
342: 
343: /**
344:  * Used when a datasource cannot be found.
345:  *
346:  * @package       Cake.Error
347:  */
348: class MissingDatasourceException extends CakeException {
349:     protected $_messageTemplate = 'Datasource class %s could not be found.';
350: }
351: 
352: /**
353:  * Exception class to be thrown when a database table is not found in the datasource
354:  *
355:  * @package       Cake.Error
356:  */
357: class MissingTableException extends CakeException {
358:     protected $_messageTemplate = 'Database table %s for model %s was not found.';
359: }
360: 
361: /**
362:  * Exception raised when a Model could not be found.
363:  *
364:  * @package       Cake.Error
365:  */
366: class MissingModelException extends CakeException {
367:     protected $_messageTemplate = 'Model %s could not be found.';
368: }
369: 
370: /**
371:  * Exception raised when a test loader could not be found
372:  *
373:  * @package       Cake.Error
374:  */
375: class MissingTestLoaderException extends CakeException {
376:     protected $_messageTemplate = 'Test loader %s could not be found.';
377: }
378: 
379: /**
380:  * Exception raised when a plugin could not be found
381:  *
382:  * @package       Cake.Error
383:  */
384: class MissingPluginException extends CakeException {
385:     protected $_messageTemplate = 'Plugin %s could not be found.';
386: }
387: 
388: /**
389:  * Exception class for Cache.  This exception will be thrown from Cache when it
390:  * encounters an error.
391:  *
392:  * @package       Cake.Error
393:  */
394: class CacheException extends CakeException { }
395: 
396: /**
397:  * Exception class for Router.  This exception will be thrown from Router when it
398:  * encounters an error.
399:  *
400:  * @package       Cake.Error
401:  */
402: class RouterException extends CakeException { }
403: 
404: /**
405:  * Exception class for CakeLog.  This exception will be thrown from CakeLog when it
406:  * encounters an error.
407:  *
408:  * @package       Cake.Error
409:  */
410: class CakeLogException extends CakeException { }
411: 
412: /**
413:  * Exception class for CakeSession.  This exception will be thrown from CakeSession when it
414:  * encounters an error.
415:  *
416:  * @package       Cake.Error
417:  */
418: class CakeSessionException extends CakeException { }
419: 
420: /**
421:  * Exception class for Configure.  This exception will be thrown from Configure when it
422:  * encounters an error.
423:  *
424:  * @package       Cake.Error
425:  */
426: class ConfigureException extends CakeException { }
427: 
428: /**
429:  * Exception class for Socket. This exception will be thrown from CakeSocket, CakeEmail, HttpSocket
430:  * SmtpTransport, MailTransport and HttpResponse when it encounters an error.
431:  *
432:  * @package       Cake.Error
433:  */
434: class SocketException extends CakeException { }
435: 
436: /**
437:  * Exception class for Xml.  This exception will be thrown from Xml when it
438:  * encounters an error.
439:  *
440:  * @package       Cake.Error
441:  */
442: class XmlException extends CakeException { }
443: 
444: /**
445:  * Exception class for Console libraries.  This exception will be thrown from Console library
446:  * classes when they encounter an error.
447:  *
448:  * @package       Cake.Error
449:  */
450: class ConsoleException extends CakeException { }
451: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs