Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.php Subject: Re: set_error_handler(): duplicate error Date: Wed, 16 Jun 2021 13:48:06 +0200 Lines: 43 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 7bit X-Trace: individual.net UKyWZAumhVRLM5rDeZB5UwYSX76qCR4GPWurooPE3OHFD8dPfw Cancel-Lock: sha1:CAFcb4FmfhM8KSvL7rhtG02LJAs= In-Reply-To: Xref: csiph.com comp.lang.php:18659 alex: > //error_reporting(0); > set_error_handler( > static function (int $severity, string $message, string $file, int > $line): void { > throw new InternalErrorException($message, 0, $severity, $file, > $line); > } > ); > > xxx(); > > Output: > > Fatal error: Uncaught Error: Call to undefined function xxx() in > /tmp/tmp.Ie1UVhkWcT/test.php on line 9 > > Error: Call to undefined function xxx() in /tmp/tmp.Ie1UVhkWcT/test.php > on line 9 > > Call Stack: > 0.0001 392928 1. {main}() /tmp/tmp.Ie1UVhkWcT/test.php:0 > > Why error message showing is duplicate? I can't reproduce this. When I run this script with PHP 7.4 as CLI, I only get the expected result: PHP Fatal error: Uncaught Error: Call to undefined function xxx() in D:\test-errorhandler.php:11 Stack trace: #0 {main} thrown in D:\test-errorhandler.php on line 11 Do you run the above script within a larger application which already has some kind of error handling in place? -- Arno Welzel https://arnowelzel.de