[TYPO3-core] RFC #9355: Add an error and exception handler (backported from FLOW3)

Rupert Germann rupi at gmx.li
Tue Sep 8 09:58:20 CEST 2009


hi

Ingo Renner schrieb:
...
> Notes, how it works:
> First, there is an error handler that transforms errors into exceptions

in function handleError() you check if the incoming errorlevel is 
registered in an array of errorlevels.
according to the php manual it's impossible that an e.g. "E_ERROR" error 
reaches a userdefined errorhandler:
"The following error types cannot be handled with a user defined 
function: E_ERROR, E_PARSE, E_CORE_ERROR, E_CORE_WARNING, 
E_COMPILE_ERROR, E_COMPILE_WARNING, and most of E_STRICT raised in the 
file where set_error_handler() is called."

the array of errorlevels should only contain that errors that can 
actually reach handleError().

> Then there are two different exception handler, one for production, and 
> one for debugging / development.
> The debug exception handler shows a nice backtrace of the exception. The 
> production exception handler only displays a message that something went 
> wrong. 

I don't get the point why we would need a "production exception 
handler". we always recommanded to completely disable the display of php 
errors/exeptions for production sites.

The initialisation for both handlers is done directly in index_ts.php 
and init.php. That means it will slow down FE and BE of all sites.

I'd like to see a possibility to disable error and exception handling 
completely, which is not possible atm.

now to some functional thingies:
display errors is enabled in php.ini
localconf:
$TYPO3_CONF_VARS['SYS']['devIPmask'] = '*';
$TYPO3_CONF_VARS['SYS']['displayErrors'] = '1';

means: we use t3lib_error_DebugExceptionHandler

what should happen if I write the following lines to index_ts.php?
(after line 138)

function strpos() { return; }

blabla (this is a parse error]

trigger_error('E_ERROR', E_ERROR);
trigger_error('E_WARNING', E_WARNING);
trigger_error('E_PARSE', E_PARSE);
trigger_error('E_NOTICE', E_NOTICE);
trigger_error('E_CORE_ERROR', E_CORE_ERROR);
trigger_error('E_CORE_WARNING', E_CORE_WARNING);
trigger_error('E_COMPILE_ERROR', E_COMPILE_ERROR);
trigger_error('E_COMPILE_WARNING', E_COMPILE_WARNING);
trigger_error('E_USER_ERROR', E_USER_ERROR);
trigger_error('E_USER_WARNING', E_USER_WARNING);
trigger_error('E_USER_NOTICE', E_USER_NOTICE);	
trigger_error('E_STRICT', E_STRICT);
trigger_error('E_RECOVERABLE_ERROR', E_RECOVERABLE_ERROR);

throw new Exception('ExceptionException',23);
throw new Exception('ExceptionException','wrong parameter');


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

on my system I see an output from the exceptionhandler only in the 
following 2 cases:

trigger_error('E_USER_ERROR', E_USER_ERROR);
throw new Exception('ExceptionException',23);

all other tests result in no output or
Fatal error: Cannot redeclare strpos() ...
Parse error: syntax error, unexpected ...
Fatal error: Wrong parameters for Exception(...


until now I'd say: quite a lot of effort for little to no use.

or what did I overlook?

greets
rupert



More information about the TYPO3-team-core mailing list