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