note 127165 added to class.outofrangeexception

From: Date: Thu, 09 Jun 2022 12:50:41 +0000
Subject: note 127165 added to class.outofrangeexception
Groups: php.notes 
Request: Send a blank email to php-notes+get-218574@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. OutOfRange 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.outofrangeexception.php Edit -- https://main.php.net/note/edit/127165 Del: integrated -- https://main.php.net/note/delete/127165/integrated Del: useless -- https://main.php.net/note/delete/127165/useless Del: bad code -- https://main.php.net/note/delete/127165/bad+code Del: spam -- https://main.php.net/note/delete/127165/spam Del: non-english -- https://main.php.net/note/delete/127165/non-english Del: in docs -- https://main.php.net/note/delete/127165/in+docs Del: other reasons-- https://main.php.net/note/delete/127165 Reject -- https://main.php.net/note/reject/127165 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218574) next »