1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19:
20:
21: 22: 23: 24: 25: 26: 27:
28: if (!class_exists('HttpException')) {
29: class HttpException extends RuntimeException {
30: }
31: }
32:
33: 34: 35: 36: 37:
38: class BadRequestException extends HttpException {
39:
40: 41: 42: 43: 44: 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: 57: 58: 59:
60: class UnauthorizedException extends HttpException {
61:
62: 63: 64: 65: 66: 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: 79: 80: 81:
82: class ForbiddenException extends HttpException {
83:
84: 85: 86: 87: 88: 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: 101: 102: 103:
104: class NotFoundException extends HttpException {
105:
106: 107: 108: 109: 110: 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: 123: 124: 125:
126: class MethodNotAllowedException extends HttpException {
127:
128: 129: 130: 131: 132: 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: 145: 146: 147:
148: class InternalErrorException extends HttpException {
149:
150: 151: 152: 153: 154: 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: 167: 168: 169: 170:
171: class CakeException extends RuntimeException {
172:
173: 174: 175: 176: 177: 178:
179: protected $_attributes = array();
180:
181: 182: 183: 184: 185:
186: protected $_messageTemplate = '';
187:
188: 189: 190: 191: 192: 193: 194: 195: 196: 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: 208: 209: 210:
211: public function getAttributes() {
212: return $this->_attributes;
213: }
214:
215: }
216:
217: 218: 219: 220: 221: 222:
223: class MissingControllerException extends CakeException {
224:
225: protected $_messageTemplate = 'Controller class %s could not be found.';
226:
227:
228: public function __construct($message, $code = 404) {
229: parent::__construct($message, $code);
230: }
231:
232:
233: }
234:
235: 236: 237: 238: 239: 240:
241: class MissingActionException extends CakeException {
242:
243: protected $_messageTemplate = 'Action %s::%s() could not be found.';
244:
245:
246: public function __construct($message, $code = 404) {
247: parent::__construct($message, $code);
248: }
249:
250:
251: }
252:
253: 254: 255: 256: 257: 258:
259: class PrivateActionException extends CakeException {
260:
261: protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
262:
263:
264: public function __construct($message, $code = 404, Exception $previous = null) {
265: parent::__construct($message, $code, $previous);
266: }
267:
268:
269: }
270:
271: 272: 273: 274: 275:
276: class MissingComponentException extends CakeException {
277:
278: protected $_messageTemplate = 'Component class %s could not be found.';
279:
280: }
281:
282: 283: 284: 285: 286:
287: class MissingBehaviorException extends CakeException {
288:
289: protected $_messageTemplate = 'Behavior class %s could not be found.';
290:
291: }
292:
293: 294: 295: 296: 297:
298: class MissingViewException extends CakeException {
299:
300: protected $_messageTemplate = 'View file "%s" is missing.';
301:
302: }
303:
304: 305: 306: 307: 308:
309: class MissingLayoutException extends CakeException {
310:
311: protected $_messageTemplate = 'Layout file "%s" is missing.';
312:
313: }
314:
315: 316: 317: 318: 319:
320: class MissingHelperException extends CakeException {
321:
322: protected $_messageTemplate = 'Helper class %s could not be found.';
323:
324: }
325:
326: 327: 328: 329: 330:
331: class MissingDatabaseException extends CakeException {
332:
333: protected $_messageTemplate = 'Database connection "%s" could not be found.';
334:
335: }
336:
337: 338: 339: 340: 341:
342: class MissingConnectionException extends CakeException {
343:
344: protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
345:
346: public function __construct($message, $code = 500) {
347: if (is_array($message)) {
348: $message += array('enabled' => true);
349: }
350: parent::__construct($message, $code);
351: }
352:
353: }
354:
355: 356: 357: 358: 359:
360: class MissingTaskException extends CakeException {
361:
362: protected $_messageTemplate = 'Task class %s could not be found.';
363:
364: }
365:
366: 367: 368: 369: 370:
371: class MissingShellMethodException extends CakeException {
372:
373: protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
374:
375: }
376:
377: 378: 379: 380: 381:
382: class MissingShellException extends CakeException {
383:
384: protected $_messageTemplate = 'Shell class %s could not be found.';
385:
386: }
387:
388: 389: 390: 391: 392:
393: class MissingDatasourceConfigException extends CakeException {
394:
395: protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
396:
397: }
398:
399: 400: 401: 402: 403:
404: class MissingDatasourceException extends CakeException {
405:
406: protected $_messageTemplate = 'Datasource class %s could not be found.';
407:
408: }
409:
410: 411: 412: 413: 414:
415: class MissingTableException extends CakeException {
416:
417: protected $_messageTemplate = 'Table %s for model %s was not found in datasource %s.';
418:
419: }
420:
421: 422: 423: 424: 425:
426: class MissingModelException extends CakeException {
427:
428: protected $_messageTemplate = 'Model %s could not be found.';
429:
430: }
431:
432: 433: 434: 435: 436:
437: class MissingTestLoaderException extends CakeException {
438:
439: protected $_messageTemplate = 'Test loader %s could not be found.';
440:
441: }
442:
443: 444: 445: 446: 447:
448: class MissingPluginException extends CakeException {
449:
450: protected $_messageTemplate = 'Plugin %s could not be found.';
451:
452: }
453:
454: 455: 456: 457: 458:
459: class MissingDispatcherFilterException extends CakeException {
460:
461: protected $_messageTemplate = 'Dispatcher filter %s could not be found.';
462:
463: }
464:
465: 466: 467: 468: 469:
470: class AclException extends CakeException {
471: }
472:
473: 474: 475: 476: 477: 478:
479: class CacheException extends CakeException {
480: }
481:
482: 483: 484: 485: 486: 487:
488: class RouterException extends CakeException {
489: }
490:
491: 492: 493: 494: 495: 496:
497: class CakeLogException extends CakeException {
498: }
499:
500: 501: 502: 503: 504: 505:
506: class CakeSessionException extends CakeException {
507: }
508:
509: 510: 511: 512: 513: 514:
515: class ConfigureException extends CakeException {
516: }
517:
518: 519: 520: 521: 522: 523:
524: class SocketException extends CakeException {
525: }
526:
527: 528: 529: 530: 531: 532:
533: class XmlException extends CakeException {
534: }
535:
536: 537: 538: 539: 540: 541:
542: class ConsoleException extends CakeException {
543: }
544:
545: 546: 547: 548: 549:
550: class FatalErrorException extends CakeException {
551:
552: 553: 554: 555: 556: 557: 558: 559:
560: public function __construct($message, $code = 500, $file = null, $line = null) {
561: parent::__construct($message, $code);
562: if ($file) {
563: $this->file = $file;
564: }
565: if ($line) {
566: $this->line = $line;
567: }
568: }
569:
570: }
571:
572: 573: 574: 575: 576:
577: class NotImplementedException extends CakeException {
578:
579: protected $_messageTemplate = '%s is not implemented.';
580:
581:
582: public function __construct($message, $code = 501) {
583: parent::__construct($message, $code);
584: }
585:
586:
587: }
588: