note 127166 added to class.outofboundsexception
| From: | Anonymous at main dot php dot net | Date: | Thu, 09 Jun 2022 12:52:19 +0000 |
| Subject: | note 127166 added to class.outofboundsexception | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-218575@lists.php.net to get a copy of this message | ||
I would probably repeat @jacub's answer, but I see the distinction as following:
OutOfBoundsException you throw, when _you_ _set_ bounds and do not wish them to be
crossed by an external entity, but they may be.
Example: you ask for a number in range [1, 6] and user input 0 or 7 or what else. You throw an
exception indicating user error they could amend.
OutOfRangeException you throw, when you expect value within allowed boundary, but
actual operation fails.
Example: You are trying to access external API call using information provided by the API itself,
and it suddenly tell you that the reference key is not pointing to a valid object. You throw an
exception indicating internal failure that the user is unable to correct.
In both cases, the key word is "you throw". Both exceptions are generated at runtime, but
the latter describes a situation that should not happen, ever, if a system is configured correctly.
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.12.131 (proxied: 194.36.150.107)
----
Manual Page -- https://php.net/manual/en/class.outofboundsexception.php
Edit -- https://main.php.net/note/edit/127166
Del: integrated -- https://main.php.net/note/delete/127166/integrated
Del: useless -- https://main.php.net/note/delete/127166/useless
Del: bad code -- https://main.php.net/note/delete/127166/bad+code
Del: spam -- https://main.php.net/note/delete/127166/spam
Del: non-english -- https://main.php.net/note/delete/127166/non-english
Del: in docs -- https://main.php.net/note/delete/127166/in+docs
Del: other reasons-- https://main.php.net/note/delete/127166
Reject -- https://main.php.net/note/reject/127166
Search -- https://main.php.net/manage/user-notes.php