#39510 [Opn->WFx]: Error to Exception configuration

From: Date: Tue, 14 Nov 2006 14:45:04 +0000
Subject: #39510 [Opn->WFx]: Error to Exception configuration
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104965@lists.php.net to get a copy of this message
ID: 39510 Updated by: derick@php.net Reported By: marcos dot neves at gmail dot com -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: ANY PHP Version: 5.2.0 New Comment: This is something you can already do by just creating your own user defined error handler (with set_error_handler). Previous Comments: ------------------------------------------------------------------------ [2006-11-14 13:11:54] marcos dot neves at gmail dot com Description: ------------ A nice feature would be a php.ini configuration with access PHP_INI_ALL and with the name error_to_exception configured by following way: ini_set("error_to_exception", E_ALL); or in php.ini: error_to_exception = E_WARNING | E_FATAL The behavior would be that php error messages, would be converted to Exceptions. PHP could slowly create specific exception like, FileNotFoundException that is throw only when error_to_exception is enabled. Would be possible to do the follow code: Reproduce code: --------------- <? ini_set("error_to_exception", E_ALL); try { $contents = file_get_contents("path/to/file"); }catch(WarningException $e){ ... } ?> And on the future: <? ini_set("error_to_exception", E_ALL); try { $contents = file_get_contents("path/to/file"); }catch(FileNotFoundException $e){ ... }catch(FileNotReadableException $e) { ... } ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39510&edit=1

« previous php.bugs (#104965) next »