Bug #66216 [Opn]: Uncaught exception when using set_error_handler

From: Date: Mon, 02 Dec 2013 08:11:04 +0000
Subject: Bug #66216 [Opn]: Uncaught exception when using set_error_handler
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183045@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66216&edit=1

 ID:                 66216
 Updated by:         laruence@php.net
 Reported by:        bastiaan at basenlily dot me
 Summary:            Uncaught exception when using set_error_handler
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   Any
 PHP Version:        5.5.6
 Block user comment: N
 Private report:     N

 New Comment:

there is a typo in your example:

should be: echo $e->getMessage();

after fixed that, I can not reproduce the bug you were describing


Previous Comments:
------------------------------------------------------------------------
[2013-12-02 06:51:36] bastiaan at basenlily dot me

Description:
------------
I've used set_error_handler to create an error handler that throws an exception when a
scripting error happens as described here:
http://us3.php.net/manual/en/class.errorexception.php

Even though I've got my commands in a try/catch block I'm getting an uncaught exception
error.

Works fine in 5.4, breaks on 5.6

Test script:
---------------
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
  throw new Exception('Hello world');
}
set_error_handler("exception_error_handler");

try {
  // try loading a file that does not have exif data:
  $results = @exif_read_data('test.txt', 0, true);
} catch (Exception $e) {
  echo $e-> getMessage; // "We never get here..."
};

Expected result:
----------------
Expect the echo to output our error instead of raising an uncaught exception error

Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'Hello world' in
/Projects/test.php on line 8


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66216&edit=1


Thread (12 messages)

« previous php.bugs (#183045) next »