Bitrix-D7  20.0.0
main/lib/exception.php
См. документацию.
1 <?php
2 namespace Bitrix\Main;
3 
4 /**
5  * Base class for fatal exceptions
6  */
7 class SystemException extends \Exception
8 {
9  /**
10  * Creates new exception object.
11  *
12  * @param string $message
13  * @param int $code
14  * @param string $file
15  * @param int $line
16  * @param \Exception $previous
17  */
18  public function __construct($message = "", $code = 0, $file = "", $line = 0, \Exception $previous = null)
19  {
20  parent::__construct($message, $code, $previous);
21 
22  if (!empty($file) && !empty($line))
23  {
24  $this->file = $file;
25  $this->line = $line;
26  }
27  }
28 }
29 
30 /**
31  * Exception is thrown when function argument is not valid.
32  */
34 {
35  protected $parameter;
36 
37  public function __construct($message = "", $parameter = "", \Exception $previous = null)
38  {
39  parent::__construct($message, 100, '', 0, $previous);
40  $this->parameter = $parameter;
41  }
42 
43  public function getParameter()
44  {
45  return $this->parameter;
46  }
47 }
48 
49 
50 /**
51  * Exception is thrown when "empty" value is passed to a function that does not accept it as a valid argument.
52  */
54 {
55  public function __construct($parameter, \Exception $previous = null)
56  {
57  $message = sprintf("Argument '%s' is null or empty", $parameter);
58  parent::__construct($message, $parameter, $previous);
59  }
60 }
61 
62 
63 /**
64  * Exception is thrown when the value of an argument is outside the allowable range of values.
65  */
67 {
68  protected $lowerLimit;
69  protected $upperLimit;
70 
71  /**
72  * Creates new exception object.
73  *
74  * @param string $parameter Argument that generates exception
75  * @param null $lowerLimit Either lower limit of the allowable range of values or an array of allowable values
76  * @param null $upperLimit Upper limit of the allowable values
77  * @param \Exception $previous
78  */
79  public function __construct($parameter, $lowerLimit = null, $upperLimit = null, \Exception $previous = null)
80  {
81  if (is_array($lowerLimit))
82  $message = sprintf("The value of an argument '%s' is outside the allowable range of values: %s", $parameter, implode(", ", $lowerLimit));
83  elseif (($lowerLimit !== null) && ($upperLimit !== null))
84  $message = sprintf("The value of an argument '%s' is outside the allowable range of values: from %s to %s", $parameter, $lowerLimit, $upperLimit);
85  elseif (($lowerLimit === null) && ($upperLimit !== null))
86  $message = sprintf("The value of an argument '%s' is outside the allowable range of values: not greater than %s", $parameter, $upperLimit);
87  elseif (($lowerLimit !== null) && ($upperLimit === null))
88  $message = sprintf("The value of an argument '%s' is outside the allowable range of values: not less than %s", $parameter, $lowerLimit);
89  else
90  $message = sprintf("The value of an argument '%s' is outside the allowable range of values", $parameter);
91 
92  $this->lowerLimit = $lowerLimit;
93  $this->upperLimit = $upperLimit;
94 
95  parent::__construct($message, $parameter, $previous);
96  }
97 
98  public function getLowerLimitType()
99  {
100  return $this->lowerLimit;
101  }
102 
103  public function getUpperType()
104  {
105  return $this->upperLimit;
106  }
107 }
108 
109 
110 /**
111  * Exception is thrown when the type of an argument is not accepted by function.
112  */
114 {
115  protected $requiredType;
116 
117  /**
118  * Creates new exception object
119  *
120  * @param string $parameter Argument that generates exception
121  * @param string $requiredType Required type
122  * @param \Exception $previous
123  */
124  public function __construct($parameter, $requiredType = "", \Exception $previous = null)
125  {
126  if (!empty($requiredType))
127  $message = sprintf("The value of an argument '%s' must be of type %s", $parameter, $requiredType);
128  else
129  $message = sprintf("The value of an argument '%s' has an invalid type", $parameter);
130 
131  $this->requiredType = $requiredType;
132 
133  parent::__construct($message, $parameter, $previous);
134  }
135 
136  public function getRequiredType()
137  {
138  return $this->requiredType;
139  }
140 }
141 
142 
143 /**
144  * Exception is thrown when operation is not implemented but should be.
145  */
147 {
148  public function __construct($message = "", \Exception $previous = null)
149  {
150  parent::__construct($message, 140, '', 0, $previous);
151  }
152 }
153 
154 
155 /**
156  * Exception is thrown when operation is not supported.
157  */
159 {
160  public function __construct($message = "", \Exception $previous = null)
161  {
162  parent::__construct($message, 150, '', 0, $previous);
163  }
164 }
165 
166 /**
167  * Exception is thrown when a method call is invalid for current state of object.
168  */
170 {
171  public function __construct($message = "", \Exception $previous = null)
172  {
173  parent::__construct($message, 160, '', 0, $previous);
174  }
175 }
176 
177 /**
178  * Exception is thrown when object property is not valid.
179  */
181 {
182  public function __construct($parameter = "", \Exception $previous = null)
183  {
184  parent::__construct("Object property \"".$parameter."\" not found.", $parameter, $previous);
185  }
186 }
187 
188 /**
189  * Exception is thrown when the object can't be constructed.
190  */
192 {
193  public function __construct($message = "", \Exception $previous = null)
194  {
195  parent::__construct($message, 500, '', 0, $previous);
196  }
197 }
198 
199 /**
200  * Exception is thrown when an object is not present.
201  */
203 {
204  public function __construct($message = "", \Exception $previous = null)
205  {
206  parent::__construct($message, 510, '', 0, $previous);
207  }
208 }
209 
210 /**
211  * Exception is thrown when access is denied
212  */
214 {
215  public function __construct($message = "", \Exception $previous = null)
216  {
217  parent::__construct(($message ?: "Access denied."), 510, '', 0, $previous);
218  }
219 }
220 
222 {
223 }
Bitrix\Main\SystemException\__construct
__construct($message="", $code=0, $file="", $line=0, \Exception $previous=null)
Creates new exception object.
Definition: main/lib/exception.php:18
Bitrix\Main\ObjectNotFoundException\__construct
__construct($message="", \Exception $previous=null)
Definition: main/lib/exception.php:204
Bitrix\Main\ArgumentException\getParameter
getParameter()
Definition: main/lib/exception.php:43
Bitrix\Main\ArgumentOutOfRangeException\__construct
__construct($parameter, $lowerLimit=null, $upperLimit=null, \Exception $previous=null)
Creates new exception object.
Definition: main/lib/exception.php:79
Bitrix\Main\ObjectException
Exception is thrown when the object can't be constructed.
Definition: main/lib/exception.php:191
Bitrix\Main
Bitrix\Main\ObjectNotFoundException
Exception is thrown when an object is not present.
Definition: main/lib/exception.php:202
Bitrix\Main\ArgumentTypeException\__construct
__construct($parameter, $requiredType="", \Exception $previous=null)
Creates new exception object.
Definition: main/lib/exception.php:124
Bitrix\Main\ArgumentTypeException\getRequiredType
getRequiredType()
Definition: main/lib/exception.php:136
Bitrix\Main\ArgumentTypeException\$requiredType
$requiredType
Definition: main/lib/exception.php:115
Bitrix\Main\DecodingException
Definition: main/lib/exception.php:221
Bitrix\Main\NotImplementedException\__construct
__construct($message="", \Exception $previous=null)
Definition: main/lib/exception.php:148
Bitrix\Main\ArgumentNullException\__construct
__construct($parameter, \Exception $previous=null)
Definition: main/lib/exception.php:55
Bitrix\Main\ArgumentOutOfRangeException\$lowerLimit
$lowerLimit
Definition: main/lib/exception.php:68
Bitrix\Main\ArgumentOutOfRangeException\getLowerLimitType
getLowerLimitType()
Definition: main/lib/exception.php:98
Bitrix\Main\ArgumentTypeException
Exception is thrown when the type of an argument is not accepted by function.
Definition: main/lib/exception.php:113
Bitrix\Main\InvalidOperationException\__construct
__construct($message="", \Exception $previous=null)
Definition: main/lib/exception.php:171
Bitrix\Main\ArgumentException
Exception is thrown when function argument is not valid.
Definition: main/lib/exception.php:33
Bitrix\Main\ObjectPropertyException
Exception is thrown when object property is not valid.
Definition: main/lib/exception.php:180
Bitrix\Main\SystemException
Base class for fatal exceptions.
Definition: main/lib/exception.php:7
Bitrix\Main\ObjectPropertyException\__construct
__construct($parameter="", \Exception $previous=null)
Definition: main/lib/exception.php:182
Bitrix\Main\AccessDeniedException\__construct
__construct($message="", \Exception $previous=null)
Definition: main/lib/exception.php:215
Bitrix\Main\ArgumentOutOfRangeException
Exception is thrown when the value of an argument is outside the allowable range of values.
Definition: main/lib/exception.php:66
Bitrix\Sender\Connector\__construct
__construct(Base $connector)
Constructor.
Definition: resultview.php:40
Bitrix\Main\NotSupportedException
Exception is thrown when operation is not supported.
Definition: main/lib/exception.php:158
Bitrix\Main\ObjectException\__construct
__construct($message="", \Exception $previous=null)
Definition: main/lib/exception.php:193
Bitrix\Main\ArgumentNullException
Exception is thrown when "empty" value is passed to a function that does not accept it as a valid arg...
Definition: main/lib/exception.php:53
Bitrix\Main\InvalidOperationException
Exception is thrown when a method call is invalid for current state of object.
Definition: main/lib/exception.php:169
Bitrix\Main\ArgumentOutOfRangeException\$upperLimit
$upperLimit
Definition: main/lib/exception.php:69
Bitrix\Main\ArgumentOutOfRangeException\getUpperType
getUpperType()
Definition: main/lib/exception.php:103
Bitrix\Main\AccessDeniedException
Exception is thrown when access is denied.
Definition: main/lib/exception.php:213
Bitrix\Main\ArgumentException\$parameter
$parameter
Definition: main/lib/exception.php:35
Bitrix\Main\ArgumentException\__construct
__construct($message="", $parameter="", \Exception $previous=null)
Definition: main/lib/exception.php:37
Bitrix\Main\NotSupportedException\__construct
__construct($message="", \Exception $previous=null)
Definition: main/lib/exception.php:160
Bitrix\Main\NotImplementedException
Exception is thrown when operation is not implemented but should be.
Definition: main/lib/exception.php:146