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: class CakeBaseException extends RuntimeException {
26:
27: 28: 29: 30: 31:
32: protected $_responseHeaders = null;
33:
34: 35: 36: 37: 38: 39: 40: 41: 42: 43:
44: public function responseHeader($header = null, $value = null) {
45: if ($header) {
46: if (is_array($header)) {
47: return $this->_responseHeaders = $header;
48: }
49: $this->_responseHeaders = array($header => $value);
50: }
51: return $this->_responseHeaders;
52: }
53:
54: }
55:
56: if (!class_exists('HttpException', false)) {
57: 58: 59: 60: 61: 62: 63: 64:
65: class HttpException extends CakeBaseException {
66: }
67: }
68:
69: 70: 71: 72: 73:
74: class BadRequestException extends HttpException {
75:
76: 77: 78: 79: 80: 81:
82: public function __construct($message = null, $code = 400) {
83: if (empty($message)) {
84: $message = 'Bad Request';
85: }
86: parent::__construct($message, $code);
87: }
88:
89: }
90:
91: 92: 93: 94: 95:
96: class UnauthorizedException extends HttpException {
97:
98: 99: 100: 101: 102: 103:
104: public function __construct($message = null, $code = 401) {
105: if (empty($message)) {
106: $message = 'Unauthorized';
107: }
108: parent::__construct($message, $code);
109: }
110:
111: }
112:
113: 114: 115: 116: 117:
118: class ForbiddenException extends HttpException {
119:
120: 121: 122: 123: 124: 125:
126: public function __construct($message = null, $code = 403) {
127: if (empty($message)) {
128: $message = 'Forbidden';
129: }
130: parent::__construct($message, $code);
131: }
132:
133: }
134:
135: 136: 137: 138: 139:
140: class NotFoundException extends HttpException {
141:
142: 143: 144: 145: 146: 147:
148: public function __construct($message = null, $code = 404) {
149: if (empty($message)) {
150: $message = 'Not Found';
151: }
152: parent::__construct($message, $code);
153: }
154:
155: }
156:
157: 158: 159: 160: 161:
162: class MethodNotAllowedException extends HttpException {
163:
164: 165: 166: 167: 168: 169:
170: public function __construct($message = null, $code = 405) {
171: if (empty($message)) {
172: $message = 'Method Not Allowed';
173: }
174: parent::__construct($message, $code);
175: }
176:
177: }
178:
179: 180: 181: 182: 183:
184: class InternalErrorException extends HttpException {
185:
186: 187: 188: 189: 190: 191:
192: public function __construct($message = null, $code = 500) {
193: if (empty($message)) {
194: $message = 'Internal Server Error';
195: }
196: parent::__construct($message, $code);
197: }
198:
199: }
200:
201: 202: 203: 204: 205: 206:
207: class CakeException extends CakeBaseException {
208:
209: 210: 211: 212: 213: 214:
215: protected $_attributes = array();
216:
217: 218: 219: 220: 221:
222: protected $_messageTemplate = '';
223:
224: 225: 226: 227: 228: 229: 230: 231: 232: 233:
234: public function __construct($message, $code = 500) {
235: if (is_array($message)) {
236: $this->_attributes = $message;
237: $message = __d('cake_dev', $this->_messageTemplate, $message);
238: }
239: parent::__construct($message, $code);
240: }
241:
242: 243: 244: 245: 246:
247: public function getAttributes() {
248: return $this->_attributes;
249: }
250:
251: }
252:
253: 254: 255: 256: 257: 258:
259: class MissingControllerException extends CakeException {
260:
261: protected $_messageTemplate = 'Controller class %s could not be found.';
262:
263:
264: public function __construct($message, $code = 404) {
265: parent::__construct($message, $code);
266: }
267:
268:
269: }
270:
271: 272: 273: 274: 275: 276:
277: class MissingActionException extends CakeException {
278:
279: protected $_messageTemplate = 'Action %s::%s() could not be found.';
280:
281:
282: public function __construct($message, $code = 404) {
283: parent::__construct($message, $code);
284: }
285:
286:
287: }
288:
289: 290: 291: 292: 293: 294:
295: class PrivateActionException extends CakeException {
296:
297: protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
298:
299:
300: public function __construct($message, $code = 404, Exception $previous = null) {
301: parent::__construct($message, $code, $previous);
302: }
303:
304:
305: }
306:
307: 308: 309: 310: 311:
312: class MissingComponentException extends CakeException {
313:
314: protected $_messageTemplate = 'Component class %s could not be found.';
315:
316: }
317:
318: 319: 320: 321: 322:
323: class MissingBehaviorException extends CakeException {
324:
325: protected $_messageTemplate = 'Behavior class %s could not be found.';
326:
327: }
328:
329: 330: 331: 332: 333:
334: class MissingViewException extends CakeException {
335:
336: protected $_messageTemplate = 'View file "%s" is missing.';
337:
338: }
339:
340: 341: 342: 343: 344:
345: class MissingLayoutException extends CakeException {
346:
347: protected $_messageTemplate = 'Layout file "%s" is missing.';
348:
349: }
350:
351: 352: 353: 354: 355:
356: class MissingHelperException extends CakeException {
357:
358: protected $_messageTemplate = 'Helper class %s could not be found.';
359:
360: }
361:
362: 363: 364: 365: 366:
367: class MissingDatabaseException extends CakeException {
368:
369: protected $_messageTemplate = 'Database connection "%s" could not be found.';
370:
371: }
372:
373: 374: 375: 376: 377:
378: class MissingConnectionException extends CakeException {
379:
380: protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
381:
382: 383: 384: 385: 386: 387:
388: public function __construct($message, $code = 500) {
389: if (is_array($message)) {
390: $message += array('enabled' => true);
391: }
392: parent::__construct($message, $code);
393: }
394:
395: }
396:
397: 398: 399: 400: 401:
402: class MissingTaskException extends CakeException {
403:
404: protected $_messageTemplate = 'Task class %s could not be found.';
405:
406: }
407:
408: 409: 410: 411: 412:
413: class MissingShellMethodException extends CakeException {
414:
415: protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
416:
417: }
418:
419: 420: 421: 422: 423:
424: class MissingShellException extends CakeException {
425:
426: protected $_messageTemplate = 'Shell class %s could not be found.';
427:
428: }
429:
430: 431: 432: 433: 434:
435: class MissingDatasourceConfigException extends CakeException {
436:
437: protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
438:
439: }
440:
441: 442: 443: 444: 445:
446: class MissingDatasourceException extends CakeException {
447:
448: protected $_messageTemplate = 'Datasource class %s could not be found. %s';
449:
450: }
451:
452: 453: 454: 455: 456:
457: class MissingTableException extends CakeException {
458:
459: protected $_messageTemplate = 'Table %s for model %s was not found in datasource %s.';
460:
461: }
462:
463: 464: 465: 466: 467:
468: class MissingModelException extends CakeException {
469:
470: protected $_messageTemplate = 'Model %s could not be found.';
471:
472: }
473:
474: 475: 476: 477: 478:
479: class MissingTestLoaderException extends CakeException {
480:
481: protected $_messageTemplate = 'Test loader %s could not be found.';
482:
483: }
484:
485: 486: 487: 488: 489:
490: class MissingPluginException extends CakeException {
491:
492: protected $_messageTemplate = 'Plugin %s could not be found.';
493:
494: }
495:
496: 497: 498: 499: 500:
501: class MissingDispatcherFilterException extends CakeException {
502:
503: protected $_messageTemplate = 'Dispatcher filter %s could not be found.';
504:
505: }
506:
507: 508: 509: 510: 511:
512: class AclException extends CakeException {
513: }
514:
515: 516: 517: 518: 519: 520:
521: class CacheException extends CakeException {
522: }
523:
524: 525: 526: 527: 528: 529:
530: class RouterException extends CakeException {
531: }
532:
533: 534: 535: 536: 537: 538:
539: class CakeLogException extends CakeException {
540: }
541:
542: 543: 544: 545: 546: 547:
548: class CakeSessionException extends CakeException {
549: }
550:
551: 552: 553: 554: 555: 556:
557: class ConfigureException extends CakeException {
558: }
559:
560: 561: 562: 563: 564: 565:
566: class SocketException extends CakeException {
567: }
568:
569: 570: 571: 572: 573: 574:
575: class XmlException extends CakeException {
576: }
577:
578: 579: 580: 581: 582: 583:
584: class ConsoleException extends CakeException {
585: }
586:
587: 588: 589: 590: 591:
592: class FatalErrorException extends CakeException {
593:
594: 595: 596: 597: 598: 599: 600: 601:
602: public function __construct($message, $code = 500, $file = null, $line = null) {
603: parent::__construct($message, $code);
604: if ($file) {
605: $this->file = $file;
606: }
607: if ($line) {
608: $this->line = $line;
609: }
610: }
611:
612: }
613:
614: 615: 616: 617: 618:
619: class NotImplementedException extends CakeException {
620:
621: protected $_messageTemplate = '%s is not implemented.';
622:
623:
624: public function __construct($message, $code = 501) {
625: parent::__construct($message, $code);
626: }
627:
628:
629: }
630:
631: 632: 633: 634: 635:
636: class SecurityException extends BadRequestException {
637:
638: 639: 640: 641:
642: protected $_type = 'secure';
643:
644: 645: 646: 647: 648:
649: protected $_reason = null;
650:
651: 652: 653: 654: 655:
656: public function getType() {
657: return $this->_type;
658: }
659:
660: 661: 662: 663: 664: 665:
666: public function setMessage($message) {
667: $this->message = $message;
668: }
669:
670: 671: 672: 673: 674: 675:
676: public function setReason($reason = null) {
677: $this->_reason = $reason;
678: }
679:
680: 681: 682: 683: 684:
685: public function getReason() {
686: return $this->_reason;
687: }
688:
689: }
690:
691: 692: 693: 694: 695:
696: class AuthSecurityException extends SecurityException {
697:
698: 699: 700: 701:
702: protected $_type = 'auth';
703:
704: }
705: