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: 382: 383: 384: 385: 386:
387: public function __construct($message, $code = 500) {
388: if (is_array($message)) {
389: $message += array('enabled' => true);
390: }
391: parent::__construct($message, $code);
392: }
393:
394: }
395:
396: 397: 398: 399: 400:
401: class MissingTaskException extends CakeException {
402:
403: protected $_messageTemplate = 'Task class %s could not be found.';
404:
405: }
406:
407: 408: 409: 410: 411:
412: class MissingShellMethodException extends CakeException {
413:
414: protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
415:
416: }
417:
418: 419: 420: 421: 422:
423: class MissingShellException extends CakeException {
424:
425: protected $_messageTemplate = 'Shell class %s could not be found.';
426:
427: }
428:
429: 430: 431: 432: 433:
434: class MissingDatasourceConfigException extends CakeException {
435:
436: protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
437:
438: }
439:
440: 441: 442: 443: 444:
445: class MissingDatasourceException extends CakeException {
446:
447: protected $_messageTemplate = 'Datasource class %s could not be found. %s';
448:
449: }
450:
451: 452: 453: 454: 455:
456: class MissingTableException extends CakeException {
457:
458: protected $_messageTemplate = 'Table %s for model %s was not found in datasource %s.';
459:
460: }
461:
462: 463: 464: 465: 466:
467: class MissingModelException extends CakeException {
468:
469: protected $_messageTemplate = 'Model %s could not be found.';
470:
471: }
472:
473: 474: 475: 476: 477:
478: class MissingTestLoaderException extends CakeException {
479:
480: protected $_messageTemplate = 'Test loader %s could not be found.';
481:
482: }
483:
484: 485: 486: 487: 488:
489: class MissingPluginException extends CakeException {
490:
491: protected $_messageTemplate = 'Plugin %s could not be found.';
492:
493: }
494:
495: 496: 497: 498: 499:
500: class MissingDispatcherFilterException extends CakeException {
501:
502: protected $_messageTemplate = 'Dispatcher filter %s could not be found.';
503:
504: }
505:
506: 507: 508: 509: 510:
511: class AclException extends CakeException {
512: }
513:
514: 515: 516: 517: 518: 519:
520: class CacheException extends CakeException {
521: }
522:
523: 524: 525: 526: 527: 528:
529: class RouterException extends CakeException {
530: }
531:
532: 533: 534: 535: 536: 537:
538: class CakeLogException extends CakeException {
539: }
540:
541: 542: 543: 544: 545: 546:
547: class CakeSessionException extends CakeException {
548: }
549:
550: 551: 552: 553: 554: 555:
556: class ConfigureException extends CakeException {
557: }
558:
559: 560: 561: 562: 563: 564:
565: class SocketException extends CakeException {
566: }
567:
568: 569: 570: 571: 572: 573:
574: class XmlException extends CakeException {
575: }
576:
577: 578: 579: 580: 581: 582:
583: class ConsoleException extends CakeException {
584: }
585:
586: 587: 588: 589: 590:
591: class FatalErrorException extends CakeException {
592:
593: 594: 595: 596: 597: 598: 599: 600:
601: public function __construct($message, $code = 500, $file = null, $line = null) {
602: parent::__construct($message, $code);
603: if ($file) {
604: $this->file = $file;
605: }
606: if ($line) {
607: $this->line = $line;
608: }
609: }
610:
611: }
612:
613: 614: 615: 616: 617:
618: class NotImplementedException extends CakeException {
619:
620: protected $_messageTemplate = '%s is not implemented.';
621:
622:
623: public function __construct($message, $code = 501) {
624: parent::__construct($message, $code);
625: }
626:
627:
628: }
629: