Re: Exceptions and builtin functions in PHP5

From: Date: Fri, 09 Apr 2004 05:42:32 +0000
Subject: Re: Exceptions and builtin functions in PHP5
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-9017@lists.php.net to get a copy of this message
> > Perhaps this could be done in userland by throwing an exception in a > user error_handler... did not test it though... > It seems that works! At least for E_WARNING: class MyException extends Exception { function __construct($errno, $errstr, $errfile, $errline) { parent::__construct($errstr, $errno); $this->file = $errfile; $this->line = $errline; } } function Error2Exception($errno, $errstr, $errfile, $errline) { throw new MyException($errno, $errstr, $errfile, $errline); } $err_msg = 'no exception'; set_error_handler('Error2Exception'); try { $con = pg_connect('host=localhost dbname=test'); } catch (Exception $e) { $err_msg = sprintf('%x - %s', $e->getCode(), $e->getMessage()); }

« previous php.internals (#9017) next »