Source for file exceptions.php

Documentation is available at exceptions.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  7. 7:  *
  8. 8:  * This source file is subject to the "Nette license" that is bundled
  9. 9:  * with this package in the file license.txt.
  10. 10:  *
  11. 11:  * For more information please see http://nettephp.com
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    http://nettephp.com/license  Nette license
  15. 15:  * @link       http://nettephp.com
  16. 16:  * @category   Nette
  17. 17:  * @package    Nette
  18. 18:  */
  19. 19:  
  20. 20: // no namespace
  21. 21:  
  22. 22:  
  23. 23:  
  24. 24: /*
  25. 25: some useful SPL exception:
  26. 26:  
  27. 27: - LogicException
  28. 28:     - InvalidArgumentException
  29. 29:     - LengthException
  30. 30: - RuntimeException
  31. 31:     - OutOfBoundsException
  32. 32:     - UnexpectedValueException
  33. 33:  
  34. 34: other SPL exceptions are ambiguous; do not use them
  35. 35:  
  36. 36: ErrorException is corrupted in PHP < 5.3
  37. 37: */
  38. 38:  
  39. 39:  
  40. 40:  
  41. 41: /**
  42. 42:  * The exception that is thrown when the value of an argument is
  43. 43:  * outside the allowable range of values as defined by the invoked method.
  44. 44:  * @package    Nette
  45. 45:  */
  46. 46: class ArgumentOutOfRangeException extends InvalidArgumentException
  47. 47: {
  48. 48: }
  49. 49:  
  50. 50:  
  51. 51:  
  52. 52: /**
  53. 53:  * The exception that is thrown when a method call is invalid for the object's
  54. 54:  * current state, method has been invoked at an illegal or inappropriate time.
  55. 55:  * @package    Nette
  56. 56:  */
  57. 57: class InvalidStateException extends RuntimeException
  58. 58: {
  59. 59:     
  60. 60:     function __construct($message ''$code 0Exception $previous NULL)
  61. 61:     {
  62. 62:         if (version_compare(PHP_VERSION '5.3''<')) {
  63. 63:             $this->previous $previous;
  64. 64:             parent::__construct($message$code);
  65. 65:         else {
  66. 66:             parent::__construct($message$code$previous);
  67. 67:         }
  68. 68:     }
  69. 69:     
  70. 70: }
  71. 71:  
  72. 72:  
  73. 73:  
  74. 74: /**
  75. 75:  * The exception that is thrown when a requested method or operation is not implemented.
  76. 76:  * @package    Nette
  77. 77:  */
  78. 78: class NotImplementedException extends LogicException
  79. 79: {
  80. 80: }
  81. 81:  
  82. 82:  
  83. 83:  
  84. 84: /**
  85. 85:  * The exception that is thrown when an invoked method is not supported. For scenarios where
  86. 86:  * it is sometimes possible to perform the requested operation, see InvalidStateException.
  87. 87:  * @package    Nette
  88. 88:  */
  89. 89: class NotSupportedException extends LogicException
  90. 90: {
  91. 91: }
  92. 92:  
  93. 93:  
  94. 94:  
  95. 95: /**
  96. 96:  * The exception that is thrown when a requested method or operation is deprecated.
  97. 97:  * @package    Nette
  98. 98:  */
  99. 102:  
  100. 103:  
  101. 104:  
  102. 105: /**
  103. 106:  * The exception that is thrown when accessing a class member (property or method) fails.
  104. 107:  * @package    Nette
  105. 108:  */
  106. 109: class MemberAccessException extends LogicException
  107. 112:  
  108. 113:  
  109. 114:  
  110. 115: /**
  111. 116:  * The exception that is thrown when an I/O error occurs.
  112. 117:  * @package    Nette
  113. 118:  */
  114. 119: class IOException extends RuntimeException
  115. 122:  
  116. 123:  
  117. 124:  
  118. 125: /**
  119. 126:  * The exception that is thrown when accessing a file that does not exist on disk.
  120. 127:  * @package    Nette
  121. 128:  */
  122. 132:  
  123. 133:  
  124. 134:  
  125. 135: /**
  126. 136:  * The exception that is thrown when part of a file or directory cannot be found.
  127. 137:  * @package    Nette
  128. 138:  */
  129. 142:  
  130. 143:  
  131. 144:  
  132. 145: /**
  133. 146:  * The exception that indicates errors that can not be recovered from. Execution of
  134. 147:  * the script should be halted.
  135. 148:  * @package    Nette
  136. 149:  */
  137. 150: class FatalErrorException extends Exception
  138. 152:     /** @var int */
  139. 153:     private $severity;
  140. 154:     
  141. 155:  
  142. 156:     public function __construct($message$code$severity$file$line$context)
  143. 157:     {
  144. 158:         
  145. 159:         parent::__construct($message$code);
  146. 160:         $this->severity $severity;
  147. 161:         $this->file $file;
  148. 162:         $this->line $line;
  149. 163:         $this->context $context;
  150. 164:     }
  151. 165:  
  152. 166:  
  153. 167:     
  154. 168:     public function getSeverity()
  155. 169:     {
  156. 170:         return $this->severity;
  157. 171:     }
  158. 172:     
  159. 173: