Bug #75954 [Nab]: E_RECOVERABLE_ERROR Not Caught

From: Date: Wed, 14 Feb 2018 21:17:20 +0000
Subject: Bug #75954 [Nab]: E_RECOVERABLE_ERROR Not Caught
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213963@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75954&edit=1

 ID:                 75954
 Updated by:         requinix@php.net
 Reported by:        johnpaulwallway at gmail dot com
 Summary:            E_RECOVERABLE_ERROR Not Caught
 Status:             Not a bug
 Type:               Bug
 Package:            *General Issues
 Operating System:   Linux: 14.04.5 LTS, Trusty Tahr
 PHP Version:        7.0.27
 Block user comment: N
 Private report:     N

 New Comment:

E_ERROR and E_RECOVERABLE_ERROR are not classes.
http://php.net/manual/en/errorfunc.constants.php

Here's an amazing resource to help you learn more:
https://www.google.com/search?q=php+error+handling


Previous Comments:
------------------------------------------------------------------------
[2018-02-14 20:52:00] johnpaulwallway at gmail dot com

nikic@php.net

I see. So, E_ERROR and E_RECOVERABLE_ERROR do not inherit from Throwable or from Error? Also, is
there any public information about the technical reasons these ERRORs cannot subclass Error?

Thanks

------------------------------------------------------------------------
[2018-02-13 09:39:39] nikic@php.net

Since PHP 7, fatal and recoverable fatal errors are used specifically in situations where throwing
an exception is not possible for technical reasons. These cases will be ported to throw Error
exceptions if and when the technical issues are resolved.

------------------------------------------------------------------------
[2018-02-13 02:27:12] johnpaulwallway at gmail dot com

Description:
------------
E_RECOVERABLE_ERROR halts the interpreter. While shutdown_function is called, one cannot handle
framework shutdown, responses, and logging in an appropriate manner.

E_RECOVERABLE_ERROR should be catchable by a catch( Throwable $t) or catch(ERROR
$e), and finally blocks _must_ be executed.

Test script:
---------------
<?php

$x = new stdClass();
try {
	echo $x;
} catch (Throwable $t) {
	echo "Yeah, we couldn't convert that to a string. Log error and respond to client's
request";
	echo $t->__toString();
} finally {
	echo "Seriously? I must be wrong";
}

Expected result:
----------------
Something like:
Yeah, we couldn't convert that to a string. Log error and respond to client's request.

E_RECOVERABLE_ERROR: Object of class stdClass could not be converted to string

Seriously? I must be wrong



Actual result:
--------------
PHP Catchable fatal error:  Object of class stdClass could not be converted to string in
/tmp/foo.php on line 5
PHP Stack trace:
PHP   1. {main}() /tmp/foo.php:0

Catchable fatal error: Object of class stdClass could not be converted to string in /tmp/foo.php on
line 5


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



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


Thread (5 messages)

« previous php.bugs (#213963) next »