Handling Exit Statuses and Exception Levels
Posted: Thu Aug 31, 2006 4:15 am
If your script needs to exit with a different status based on the seriousness of the exception, is it cheating to use the Error Code from the Exception?
Example Usage:
or should I stick to the following to avoid confusion...
Code: Select all
// Warning
throw new Exception($message, 1, __CLASS__);
// Fatal
throw new Exception($message, 2, __CLASS__);Code: Select all
try {
// Script
} catch (Exception $e) {
// I will be doing more with this based on warning or fatal, but for now ...
exit($e->getCode());
}Code: Select all
class Warning_Exception extends Exception { }
class Fatal_Exception extends Exception { }