|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-02-25 07:12 UTC] ceefour at gauldong dot net
Description:
------------
When an exception is thrown inside an exception handler, a "exception thrown without stack frame in unknown on line 0" message is displayed.
While the meaning of this message is "clear" enough... it doesn't help at all.
If you trigger_error() inside an error handler, the default error handler is triggered, but still showing meaningful/helpful error message. Exceptions inside exception handler should behave similarly.
Reproduce code:
---------------
// do this inside an exception handler function
throw new Exception('test');
Expected result:
----------------
...file something.php on line 483...
Actual result:
--------------
...unknown on line 0....
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 17:00:01 2025 UTC |
<?php function exception_handler($exception) { trigger_error("user error"); throw new Exception('exception1'); } set_exception_handler('exception_handler'); throw new Exception('exception2'); ?>This modified code may be better illustrate the problem: <?php function error_handler() { trigger_error("inside error", E_USER_ERROR); } set_error_handler('error_handler'); trigger_error("outside error", E_USER_ERROR); function exception_handler($exception) { throw new Exception('inside exception'); } set_exception_handler('exception_handler'); throw new Exception('outside exception'); ?>Got the same Problem with the ErrorHandler Just in win32. In Linux this works great. SourceCode: ------------------------------------------- --- header.php (Load before any output started or other PHP files loaded) set_error_handler(array('main','handleError'), E_ALL); --- main.class.php final class main { [...] public static function handleError($errorNo, $message, $filename, $lineNo) { $errReport = error_reporting(); if ($errReport != 0) { if ($errorNo != 8) { $type = 'error'; switch ($errorNo) { case 2: $type = 'warning'; break; } throw new SystemException('PHP '.$type.' in file '.$filename.' ('.$lineNo.'): '.$message, 0); } } } [...] } --- systemexception.class.php (loaded before main.class.php) require_once('exceptions/printableexception.class.php'); class SystemException extends Exception implements PrintableException { [...] public function show() { echo '...[...template...]...'; } [...] } --- printableexception.class.php interface PrintableException { public function show(); } ----------- EOF -------------- On Linux Systems: anything works great! On Windows Systems: Exception thrown without a stack frame in Unknown on line 0This problem is still present as of PHP 5.3.2 on Ubuntu 10.04 using the following test cases: <?php // Example 1 function exceptionHandlerFunc() { throw new Exception("This message should be visible!"); } set_exception_handler("exceptionHandlerFunc"); throw new Exception("Something bad happened"); ?> <?php // Example 2 function shutdownFunc() { throw new Exception("This message should be visible!"); } register_shutdown_function('shutdownFunc'); ?> <?php // Example 3 class MyClass { public function __destruct() { throw new Exception("This message should be visible!"); } } $test = new MyClass(); ?> All result in this error: 'Fatal error: Exception thrown without a stack frame in Unknown on line 0' While I can understand their may be complexities with stack traces, and even file and line numbers in these contexts, the original error message should at least be visible so that it can be debugged and resolved, i.e. Fatal error: Exception (type: Exception, message: 'This message should be visible!') thrown without a stack frame in Unknown on line 0.