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: class BadRequestException extends HttpException {
38: 39: 40: 41: 42: 43:
44: public function __construct($message = null, $code = 400) {
45: if (empty($message)) {
46: $message = 'Bad Request';
47: }
48: parent::__construct($message, $code);
49: }
50: }
51:
52: 53: 54: 55: 56:
57: class UnauthorizedException extends HttpException {
58: 59: 60: 61: 62: 63:
64: public function __construct($message = null, $code = 401) {
65: if (empty($message)) {
66: $message = 'Unauthorized';
67: }
68: parent::__construct($message, $code);
69: }
70: }
71:
72: 73: 74: 75: 76:
77: class ForbiddenException extends HttpException {
78: 79: 80: 81: 82: 83:
84: public function __construct($message = null, $code = 403) {
85: if (empty($message)) {
86: $message = 'Forbidden';
87: }
88: parent::__construct($message, $code);
89: }
90: }
91:
92: 93: 94: 95: 96:
97: class NotFoundException extends HttpException {
98: 99: 100: 101: 102: 103:
104: public function __construct($message = null, $code = 404) {
105: if (empty($message)) {
106: $message = 'Not Found';
107: }
108: parent::__construct($message, $code);
109: }
110: }
111:
112: 113: 114: 115: 116:
117: class MethodNotAllowedException extends HttpException {
118: 119: 120: 121: 122: 123:
124: public function __construct($message = null, $code = 405) {
125: if (empty($message)) {
126: $message = 'Method Not Allowed';
127: }
128: parent::__construct($message, $code);
129: }
130: }
131:
132: 133: 134: 135: 136:
137: class InternalErrorException extends HttpException {
138: 139: 140: 141: 142: 143:
144: public function __construct($message = null, $code = 500) {
145: if (empty($message)) {
146: $message = 'Internal Server Error';
147: }
148: parent::__construct($message, $code);
149: }
150: }
151:
152: 153: 154: 155: 156: 157:
158: class CakeException extends RuntimeException {
159: 160: 161: 162: 163: 164:
165: protected $_attributes = array();
166:
167: 168: 169: 170: 171:
172: protected $_messageTemplate = '';
173:
174: 175: 176: 177: 178: 179: 180: 181: 182: 183:
184: public function __construct($message, $code = 500) {
185: if (is_array($message)) {
186: $this->_attributes = $message;
187: $message = __d('cake_dev', $this->_messageTemplate, $message);
188: }
189: parent::__construct($message, $code);
190: }
191:
192: 193: 194: 195: 196:
197: public function getAttributes() {
198: return $this->_attributes;
199: }
200: }
201:
202: 203: 204: 205: 206: 207:
208: class MissingControllerException extends CakeException {
209: protected $_messageTemplate = 'Controller class %s could not be found.';
210:
211: public function __construct($message, $code = 404) {
212: parent::__construct($message, $code);
213: }
214: }
215:
216: 217: 218: 219: 220: 221:
222: class MissingActionException extends CakeException {
223: protected $_messageTemplate = 'Action %s::%s() could not be found.';
224:
225: public function __construct($message, $code = 404) {
226: parent::__construct($message, $code);
227: }
228: }
229:
230: 231: 232: 233: 234: 235:
236: class PrivateActionException extends CakeException {
237: protected $_messageTemplate = 'Private Action %s::%s() is not directly accessible.';
238:
239: public function __construct($message, $code = 404, Exception $previous = null) {
240: parent::__construct($message, $code, $previous);
241: }
242: }
243:
244: 245: 246: 247: 248:
249: class MissingComponentException extends CakeException {
250: protected $_messageTemplate = 'Component class %s could not be found.';
251: }
252:
253: 254: 255: 256: 257:
258: class MissingBehaviorException extends CakeException {
259: protected $_messageTemplate = 'Behavior class %s could not be found.';
260: }
261:
262: 263: 264: 265: 266:
267: class MissingViewException extends CakeException {
268: protected $_messageTemplate = 'View file "%s" is missing.';
269: }
270:
271: 272: 273: 274: 275:
276: class MissingLayoutException extends CakeException {
277: protected $_messageTemplate = 'Layout file "%s" is missing.';
278: }
279:
280: 281: 282: 283: 284:
285: class MissingHelperException extends CakeException {
286: protected $_messageTemplate = 'Helper class %s could not be found.';
287: }
288:
289: 290: 291: 292: 293:
294: class MissingDatabaseException extends CakeException {
295: protected $_messageTemplate = 'Database connection "%s" could not be found.';
296: }
297:
298: 299: 300: 301: 302:
303: class MissingConnectionException extends CakeException {
304: protected $_messageTemplate = 'Database connection "%s" is missing, or could not be created.';
305: }
306:
307: 308: 309: 310: 311:
312: class MissingTaskException extends CakeException {
313: protected $_messageTemplate = 'Task class %s could not be found.';
314: }
315:
316: 317: 318: 319: 320:
321: class MissingShellMethodException extends CakeException {
322: protected $_messageTemplate = "Unknown command %1\$s %2\$s.\nFor usage try `cake %1\$s --help`";
323: }
324:
325: 326: 327: 328: 329:
330: class MissingShellException extends CakeException {
331: protected $_messageTemplate = 'Shell class %s could not be found.';
332: }
333:
334: 335: 336: 337: 338:
339: class MissingDatasourceConfigException extends CakeException {
340: protected $_messageTemplate = 'The datasource configuration "%s" was not found in database.php';
341: }
342:
343: 344: 345: 346: 347:
348: class MissingDatasourceException extends CakeException {
349: protected $_messageTemplate = 'Datasource class %s could not be found.';
350: }
351:
352: 353: 354: 355: 356:
357: class MissingTableException extends CakeException {
358: protected $_messageTemplate = 'Database table %s for model %s was not found.';
359: }
360:
361: 362: 363: 364: 365:
366: class MissingModelException extends CakeException {
367: protected $_messageTemplate = 'Model %s could not be found.';
368: }
369:
370: 371: 372: 373: 374:
375: class MissingTestLoaderException extends CakeException {
376: protected $_messageTemplate = 'Test loader %s could not be found.';
377: }
378:
379: 380: 381: 382: 383:
384: class MissingPluginException extends CakeException {
385: protected $_messageTemplate = 'Plugin %s could not be found.';
386: }
387:
388: 389: 390: 391: 392: 393:
394: class CacheException extends CakeException { }
395:
396: 397: 398: 399: 400: 401:
402: class RouterException extends CakeException { }
403:
404: 405: 406: 407: 408: 409:
410: class CakeLogException extends CakeException { }
411:
412: 413: 414: 415: 416: 417:
418: class CakeSessionException extends CakeException { }
419:
420: 421: 422: 423: 424: 425:
426: class ConfigureException extends CakeException { }
427:
428: 429: 430: 431: 432: 433:
434: class SocketException extends CakeException { }
435:
436: 437: 438: 439: 440: 441:
442: class XmlException extends CakeException { }
443:
444: 445: 446: 447: 448: 449:
450: class ConsoleException extends CakeException { }
451: