Welcome Guest, Not a member yet? Register   Sign In
Handing errors in my code using Exceptions
#3

I don't have a lot of experience using Exceptions in CodeIgniter, but, coming from other environments (primarily other programming languages), the actions I'm willing to take once an exception has occurred are usually pretty limited, because it indicates that the system/application is in an unexpected state. The fact that the "finally" clause was only added in PHP 5.5 just adds to the mess, because it is even less likely that you can sensibly continue execution after an exception without it.

Additionally, though I'm sure it's just a simplified example, I'd really expect an InvalidArgumentException for the ! is_numeric($a) check and maybe a RangeException for the $a > 2 check. While it may be valid in your case, ErrorException appears to be intended to handle the conversion of errors into Exceptions, especially in cases where there may not be a more appropriate type of Exception available.
Reply


Messages In This Thread
RE: Handing errors in my code using Exceptions - by mwhitney - 09-21-2015, 07:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB