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