On 6/11/2016 5:48 PM, Fleshgrinder wrote:
> Currently error_get_last() always contains the last error that occurred,
> however, this is actually not desired if the last error was an exception
> that was caught.
Changing the behaviour of how errors are handled, to depend on what
happens after the error occurs, seems a really bad choice to me.
From https://bugs.php.net/bug.php?id=54043
> If you create a custom error handler which converts all PHP errors to exceptions,
> catching internal exceptions inline therefore throws another Exception in the custom error handler,
Can you provide a reproduce case for this? The code below has a custom
error handler; it is never called.
It's actually not that clear what problem you are trying to solve here.
> Should we treat it as a simple bug fix?
No, I don't think we can. First, wrong behaviour is a design flaw not
a bug, and second it's really not obvious that having weird complex
behaviour would be preferrable.
On 26 June 2016 at 08:08, Fleshgrinder <php@fleshgrinder.com> wrote:
> Any feedback here?
This month you've sent almost 4 emails a day to this list. That is an
incredibly high number for a list that is distributed to thousands of
people. This list would be much better served if there were fewer
emails, that contained more fully thought through proposals.
cheers
Dan
<?php
error_reporting(E_ALL);
set_error_handler('tierErrorHandler');
register_shutdown_function('shutdown');
$time = '9999-11-33'; // invalid
$timeZone = new DateTimeZone('UTC');
try {
$dateTime = new DateTime($time, $timeZone);
} catch (Exception $e) {
var_dump('Exception:', $e->getMessage());
}
echo 'END' . PHP_EOL;
function shutdown()
{
$error = error_get_last();
var_dump('Error ', @$error);
}
function tierErrorHandler($errorNumber, $errorMessage, $errorFile, $errorLine) {
echo "Is this called?" . PHP_EOL;
$message = "Error: [$errorNumber] $errorMessage in file $errorFile
on line $errorLine<br />\n";
throw new \Exception($message);
}