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.1 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.1
      • 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
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
    • Network
      • Email
      • Http
    • Routing
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • ErrorHandler
  • ExceptionRenderer

Exceptions

  • AclException
  • 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-2012, 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-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 15:  * @link          http://book.cakephp.org/2.0/en/development/testing.html
 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: /**
 34:  * Represents an HTTP 400 error.
 35:  *
 36:  * @package       Cake.Error
 37:  */
 38: class BadRequestException extends HttpException {
 39: 
 40: /**
 41:  * Constructor
 42:  *
 43:  * @param string $message If no message is given 'Bad Request' will be the message
 44:  * @param string $code Status code, defaults to 400
 45:  */
 46:     public function __construct($message = null, $code = 400) {
 47:         if (empty($message)) {
 48:             $message = 'Bad Request';
 49:         }
 50:         parent::__construct($message, $code);
 51:     }
 52: 
 53: }
 54: 
 55: /**
 56:  * Represents an HTTP 401 error.
 57:  *
 58:  * @package       Cake.Error
 59:  */
 60: class UnauthorizedException extends HttpException {
 61: 
 62: /**
 63:  * Constructor
 64:  *
 65:  * @param string $message If no message is given 'Unauthorized' will be the message
 66:  * @param string $code Status code, defaults to 401
 67:  */
 68:     public function __construct($message = null, $code = 401) {
 69:         if (empty($message)) {
 70:             $message = 'Unauthorized';
 71:         }
 72:         parent::__construct($message, $code);
 73:     }
 74: 
 75: }
 76: 
 77: /**
 78:  * Represents an HTTP 403 error.
 79:  *
 80:  * @package       Cake.Error
 81:  */
 82: class ForbiddenException extends HttpException {
 83: 
 84: /**
 85:  * Constructor
 86:  *
 87:  * @param string $message If no message is given 'Forbidden' will be the message
 88:  * @param string $code Status code, defaults to 403
 89:  */
 90:     public function __construct($message = null, $code = 403) {
 91:         if (empty($message)) {
 92:             $message = 'Forbidden';
 93:         }
 94:         parent::__construct($message, $code);
 95:     }
 96: 
 97: }
 98: 
 99: /**
100:  * Represents an HTTP 404 error.
101:  *
102:  * @package       Cake.Error
103:  */
104: class NotFoundException extends HttpException {
105: 
106: /**
107:  * Constructor
108:  *
109:  * @param string $message If no message is given 'Not Found' will be the message
110:  * @param string $code Status code, defaults to 404
111:  */
112:     public function __construct($message = null, $code = 404) {
113:         if (empty($message)) {
114:             $message = 'Not Found';
115:         }
116:         parent::__construct($message, $code);
117:     }
118: 
119: }
120: 
121: /**
122:  * Represents an HTTP 405 error.
123:  *
124:  * @package       Cake.Error
125:  */
126: class MethodNotAllowedException extends HttpException {
127: 
128: /**
129:  * Constructor
130:  *
131:  * @param string $message If no message is given 'Method Not Allowed' will be the message
132:  * @param string $code Status code, defaults to 405
133:  */
134:     public function __construct($message = null, $code = 405) {
135:         if (empty($message)) {
136:             $message = 'Method Not Allowed';
137:         }
138:         parent::__construct($message, $code);
139:     }
140: 
141: }
142: 
143: /**
144:  * Represents an HTTP 500 error.
145:  *
146:  * @package       Cake.Error
147:  */
148: class InternalErrorException extends HttpException {
149: 
150: /**
151:  * Constructor
152:  *
153:  * @param string $message If no message is given 'Internal Server Error' will be the message
154:  * @param string $code Status code, defaults to 500
155:  */
156:     public function __construct($message = null, $code = 500) {
157:         if (empty($message)) {
158:             $message = 'Internal Server Error';
159:         }
160:         parent::__construct($message, $code);
161:     }
162: 
163: }
164: 
165: /**
166:  * CakeException is used a base class for CakePHP's internal exceptions.
167:  * In general framework errors are interpreted as 500 code errors.
168:  *
169:  * @package       Cake.Error
170:  */
171: class CakeException extends RuntimeException {
172: 
173: /**
174:  * Array of attributes that are passed in from the constructor, and
175:  * made available in the view when a development error is displayed.
176:  *
177:  * @var array
178:  */
179:     protected $_attributes = array();
180: 
181: /**
182:  * Template string that has attributes sprintf()'ed into it.
183:  *
184:  * @var string
185:  */
186:     protected $_messageTemplate = '';
187: 
188: /**
189:  * Constructor.
190:  *
191:  * Allows you to create exceptions that are treated as framework errors and disabled
192:  * when debug = 0.
193:  *
194:  * @param mixed $message Either the string of the error message, or an array of attributes
195:  *   that are made available in the view, and sprintf()'d into CakeException::$_messageTemplate
196:  * @param string $code The code of the error, is also the HTTP status code for the error.
197:  */
198:     public function __construct($message, $code = 500) {
199:         if (is_array($message)) {
200:             $this->_attributes = $message;
201:             $message = __d('cake_dev', $this->_messageTemplate, $message);
202:         }
203:         parent::__construct($message, $code);
204:     }
205: 
206: /**
207:  * Get the passed in attributes
208:  *
209:  * @return array
210:  */
211:     public function getAttributes() {
212:         return $this->_attributes;
213:     }
214: 
215: }
216: 
217: /**
218:  * Missing Controller exception - used when a controller
219:  * cannot be found.
220:  *
221:  * @package       Cake.Error
222:  */
223: class MissingControllerException extends CakeException {
224: 
225:     protected $_messageTemplate = 'Controller class %s could not be found.';
226: 
227:     public function __construct($message, $code = 404) {
228:         parent::__construct($message, $code);
229:     }
230: 
231: }
232: 
233: /**
234:  * Missing Action exception - used when a controller action
235:  * cannot be found.
236:  *
237:  * @package       Cake.Error
238:  */
239: class MissingActionException extends CakeException {
240: 
241:     protected $_messageTemplate = 'Action %s::%s() could not be found.';
242: 
243:     public function __construct($message, $code = 404) {
244:         parent::__construct($message, $code);
245:     }
246: 
247: }
248: 
249: /**
250:  * Private Action exception - used when a controller action
251:  * starts with a  `_`.
252:  *
253:  * @package       Cake.Error
254:  */
255: class PrivateActionException extends CakeException {
256: 
257:     protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
258: 
259:     public function __construct($message, $code = 404, Exception $previous = null) {
260:         parent::__construct($message, $code, $previous);
261:     }
262: 
263: }
264: 
265: /**
266:  * Used when a component cannot be found.
267:  *
268:  * @package       Cake.Error
269:  */
270: class MissingComponentException extends CakeException {
271: 
272:     protected $_messageTemplate = 'Component class %s could not be found.';
273: 
274: }
275: 
276: /**
277:  * Used when a behavior cannot be found.
278:  *
279:  * @package       Cake.Error
280:  */
281: class MissingBehaviorException extends CakeException {
282: 
283:     protected $_messageTemplate = 'Behavior class %s could not be found.';
284: 
285: }
286: 
287: /**
288:  * Used when a view file cannot be found.
289:  *
290:  * @package       Cake.Error
291:  */
292: class MissingViewException extends CakeException {
293: 
294:     protected $_messageTemplate = 'View file "%s" is missing.';
295: 
296: }
297: 
298: /**
299:  * Used when a layout file cannot be found.
300:  *
301:  * @package       Cake.Error
302:  */
303: class MissingLayoutException extends CakeException {
304: 
305:     protected $_messageTemplate = 'Layout file "%s" is missing.';
306: 
307: }
308: 
309: /**
310:  * Used when a helper cannot be found.
311:  *
312:  * @package       Cake.Error
313:  */
314: class MissingHelperException extends CakeException {
315: 
316:     protected $_messageTemplate = 'Helper class %s could not be found.';
317: 
318: }
319: 
320: /**
321:  * Runtime Exceptions for ConnectionManager
322:  *
323:  * @package       Cake.Error
324:  */
325: class MissingDatabaseException extends CakeException {
326: 
327:     protected $_messageTemplate = 'Database connection "%s" could not be found.';
328: 
329: }
330: 
331: /**
332:  * Used when no connections can be found.
333:  *
334:  * @package       Cake.Error
335:  */
336: class MissingConnectionException extends CakeException {
337: 
338:     protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
339: 
340:     public function __construct($message, $code = 500) {
341:         if (is_array($message)) {
342:             $message += array('enabled' => true);
343:         }
344:         parent::__construct($message, $code);
345:     }
346: }
347: 
348: /**
349:  * Used when a Task cannot be found.
350:  *
351:  * @package       Cake.Error
352:  */
353: class MissingTaskException extends CakeException {
354: 
355:     protected $_messageTemplate = 'Task class %s could not be found.';
356: 
357: }
358: 
359: /**
360:  * Used when a shell method cannot be found.
361:  *
362:  * @package       Cake.Error
363:  */
364: class MissingShellMethodException extends CakeException {
365: 
366:     protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
367: 
368: }
369: 
370: /**
371:  * Used when a shell cannot be found.
372:  *
373:  * @package       Cake.Error
374:  */
375: class MissingShellException extends CakeException {
376: 
377:     protected $_messageTemplate = 'Shell class %s could not be found.';
378: 
379: }
380: 
381: /**
382:  * Exception class to be thrown when a datasource configuration is not found
383:  *
384:  * @package       Cake.Error
385:  */
386: class MissingDatasourceConfigException extends CakeException {
387: 
388:     protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
389: 
390: }
391: 
392: /**
393:  * Used when a datasource cannot be found.
394:  *
395:  * @package       Cake.Error
396:  */
397: class MissingDatasourceException extends CakeException {
398: 
399:     protected $_messageTemplate = 'Datasource class %s could not be found.';
400: 
401: }
402: 
403: /**
404:  * Exception class to be thrown when a database table is not found in the datasource
405:  *
406:  * @package       Cake.Error
407:  */
408: class MissingTableException extends CakeException {
409: 
410:     protected $_messageTemplate = 'Table %s for model %s was not found in datasource %s.';
411: 
412: }
413: 
414: /**
415:  * Exception raised when a Model could not be found.
416:  *
417:  * @package       Cake.Error
418:  */
419: class MissingModelException extends CakeException {
420: 
421:     protected $_messageTemplate = 'Model %s could not be found.';
422: 
423: }
424: 
425: /**
426:  * Exception raised when a test loader could not be found
427:  *
428:  * @package       Cake.Error
429:  */
430: class MissingTestLoaderException extends CakeException {
431: 
432:     protected $_messageTemplate = 'Test loader %s could not be found.';
433: 
434: }
435: 
436: /**
437:  * Exception raised when a plugin could not be found
438:  *
439:  * @package       Cake.Error
440:  */
441: class MissingPluginException extends CakeException {
442: 
443:     protected $_messageTemplate = 'Plugin %s could not be found.';
444: 
445: }
446: 
447: /**
448:  * Exception class for AclComponent and Interface implementations.
449:  *
450:  * @package       Cake.Error
451:  */
452: class AclException extends CakeException {
453: }
454: 
455: /**
456:  * Exception class for Cache.  This exception will be thrown from Cache when it
457:  * encounters an error.
458:  *
459:  * @package       Cake.Error
460:  */
461: class CacheException extends CakeException {
462: }
463: 
464: /**
465:  * Exception class for Router.  This exception will be thrown from Router when it
466:  * encounters an error.
467:  *
468:  * @package       Cake.Error
469:  */
470: class RouterException extends CakeException {
471: }
472: 
473: /**
474:  * Exception class for CakeLog.  This exception will be thrown from CakeLog when it
475:  * encounters an error.
476:  *
477:  * @package       Cake.Error
478:  */
479: class CakeLogException extends CakeException {
480: }
481: 
482: /**
483:  * Exception class for CakeSession.  This exception will be thrown from CakeSession when it
484:  * encounters an error.
485:  *
486:  * @package       Cake.Error
487:  */
488: class CakeSessionException extends CakeException {
489: }
490: 
491: /**
492:  * Exception class for Configure.  This exception will be thrown from Configure when it
493:  * encounters an error.
494:  *
495:  * @package       Cake.Error
496:  */
497: class ConfigureException extends CakeException {
498: }
499: 
500: /**
501:  * Exception class for Socket. This exception will be thrown from CakeSocket, CakeEmail, HttpSocket
502:  * SmtpTransport, MailTransport and HttpResponse when it encounters an error.
503:  *
504:  * @package       Cake.Error
505:  */
506: class SocketException extends CakeException {
507: }
508: 
509: /**
510:  * Exception class for Xml.  This exception will be thrown from Xml when it
511:  * encounters an error.
512:  *
513:  * @package       Cake.Error
514:  */
515: class XmlException extends CakeException {
516: }
517: 
518: /**
519:  * Exception class for Console libraries.  This exception will be thrown from Console library
520:  * classes when they encounter an error.
521:  *
522:  * @package       Cake.Error
523:  */
524: class ConsoleException extends CakeException {
525: }
526: 
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