Re: Exceptions and builtin functions in PHP5

From: Date: Thu, 08 Apr 2004 11:05:36 +0000
Subject: Re: Exceptions and builtin functions in PHP5
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-8992@lists.php.net to get a copy of this message
On 8 Apr 2004 at 12:45, Derick Rethans wrote: > > I want to write: > > ... > > $res = some_builtin_func(); // func raises exception on error > > // so I don't need to write additional lines > > ... > > > > So will PHP5 (or future versions) work as in my 2nd example? > > No It would be a nice feature to let the user decide whether to throw exceptions when errors are triggered: // either ERROR_TRIGGER or ERROR_EXCEPTION error_handling(ERROR_EXCEPTION); // Don't throw exceptions for notices or warnings error_reporting(E_ERROR); try { mysql_connect() } catch (Notice $e) { echo 'Notice: ' . $e->getMessage(); } catch (Warning $e) { echo 'Warning: ' . $e->getMessage(); } catch (Error $e) { echo 'Error: ' . $e->getMessage(); } catch (Exception $e) { echo 'Unknown exception: ' . $e->getMessage(); } -- Ferdinand Beyer <fb@fbeyer.com>

« previous php.internals (#8992) next »