#32101 [Opn->Fbk]: Exception in unknown on line 0 when throwing exception inside exception handler

From: Date: Mon, 22 Oct 2007 08:48:40 +0000
Subject: #32101 [Opn->Fbk]: Exception in unknown on line 0 when throwing exception inside exception handler
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-118808@lists.php.net to get a copy of this message
 ID:               32101
 Updated by:       jani@php.net
 Reported By:      ceefour at gauldong dot net
-Status:           Open
+Status:           Feedback
 Bug Type:         Scripting Engine problem
 Operating System: *
 PHP Version:      5CVS-2005-02-15
 New Comment:

Does this still happen using latest CVS snapshot/checkout of PHP 5.2
branch?


Previous Comments:
------------------------------------------------------------------------

[2007-10-22 08:47:25] jani@php.net

See also bug #43016


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

[2007-10-18 11:26:41] ceefour at gauldong dot net

You know, "complicated" stack traces like the one you get in Java would
be much more helpful than this message. Or the one in Erlang. Or in Ruby
with Rails.

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

[2007-10-18 10:39:04] gerrit dot boettcher at gmail dot com

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 0

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

[2005-02-25 11:20:24] ceefour at gauldong dot net

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');
?>

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

[2005-02-25 11:01:19] tony2001@php.net

<?php
function exception_handler($exception) {
	trigger_error("user error");
	throw new Exception('exception1');
}
set_exception_handler('exception_handler');
throw new Exception('exception2');
?>

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/32101

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


Thread (13 messages)

« previous php.bugs (#118808) next »