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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: marcos dot neves at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 03:01:32 2025 UTC