Edit report at https://bugs.php.net/bug.php?id=47887&edit=1

 ID:                 47887
 Comment by:         notdefix at hotmail dot com
 Reported by:        aragon at phat dot za dot net
 Summary:            Permit custom error types with trigger_error()
 Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Feature/Change Request
 Operating System:   FreeBSD
 PHP Version:        5.2.9
 Block user comment: N
 Private report:     N

 New Comment:

It would be nice if a couple more error levels would be supported, for example

in addition to the supported:
  E_USER_ERROR
  E_USER_WARNING
  E_USER_NOTICE
  E_USER_DEPRECATED

please also add:
  E_USER_INFO ..: for example: 'system starting'
  E_USER_DEBUG .: for example: 'reading line 8 of config file'

This would bring it more in line with the error levels common in many systems.


Previous Comments:
------------------------------------------------------------------------
[2009-04-03 19:36:35] johan...@php.net

This isn't possible, as the whole error infrastructure, including all logging 
components and therelike have to know the error levels which might occur. You 
could use a global variable to transport your own error code for example.

------------------------------------------------------------------------
[2009-04-03 14:29:27] aragon at phat dot za dot net

Description:
------------
It would be useful if trigger_error would accept custom error types.  Although 
I can do this with Exceptions, I can't see a way of sending variable context 
from where an exception is thrown to the exception handler, and loosing 
variable context would be a deal breaker.


Reproduce code:
---------------
define('E_CUSTOM_1', -1);
define('E_CUSTOM_2', -2);
function error_handler ($errno, $errmsg, $scriptname, $scriptline, $errcontext) 
{
   if ($errno == E_CUSTOM_1) die('custom error type');
}
set_error_handler('error_handler');
trigger_user('message', E_CUSTOM_1);


Expected result:
----------------
custom error type


Actual result:
--------------
PHP Warning:  Invalid error type specified in - on line 7



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



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

Reply via email to