php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #39510 Error to Exception configuration
Submitted: 2006-11-14 13:11 UTC Modified: 2006-11-14 14:45 UTC
From: marcos dot neves at gmail dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.2.0 OS: ANY
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-11-14 13:11 UTC] 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) {
   ...
}

?>



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-14 14:45 UTC] derick@php.net
This is something you can already do by just creating your own user defined error handler (with set_error_handler).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jun 17 13:01:29 2024 UTC