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