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