Hi, I simply thought that in case of direct using of predefined Exception class, its $file and $line properties would point to my error handler function. I.e. where Exception object was created. Also its constructor does not take file/line as param-s and these properties are read-only, so I thought that there's no way to directly modify them.
"Marcus Boerger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello Tumurbaatar, > > iam curios, why would you want to change the exceptions parameters > $file and $line? They are both available through the backtrace at > the second element. Try the following: > > [...] > catch (Exception $e) > { > $trace = $e->getTrace(); > var_dump($trace[1]); > } > > That outputs: > > array(3) { > ["file"]=> > string(36) "/usr/src/php-cvs/tests/lang/038.phpt" > ["line"]=> > int(26) > ["function"]=> > string(10) "pg_connect" > } > > regards > marcus > > Friday, April 9, 2004, 7:42:32 AM, you wrote: > > >> > >> 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()); > > } > > > > > > -- > Best regards, > Marcus mailto:[EMAIL PROTECTED] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php