hackalive Posted April 3, 2010 Share Posted April 3, 2010 Hi guys, two things, where can I get a complete list of possible error cases (eg E_USER_NOTICE) and secondaly how can I make my own for the custom error handler I have thanks in advance for any/all help Quote Link to comment Share on other sites More sharing options...
ignace Posted April 3, 2010 Share Posted April 3, 2010 http://be.php.net/manual/en/errorfunc.constants.php You can only use the E_USER_* constants (NOTICE, WARNING, ERROR, DEPRECATED) You can define your own error constants but these are not usable by the built-in error handlers (unless they share the same integer value). Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 3, 2010 Author Share Posted April 3, 2010 ignace in regards to your response to the second question could you please clarify it. Can I have my own eg E_USER_AA? if so how, I am using my own error handler so I would like to know if I can do this Quote Link to comment Share on other sites More sharing options...
ignace Posted April 3, 2010 Share Posted April 3, 2010 Yes you can have your own error constants but you can't use these with any built-in error-handling functions. Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 3, 2010 Author Share Posted April 3, 2010 okay thanks ignace, so how do I build them? Quote Link to comment Share on other sites More sharing options...
ignace Posted April 3, 2010 Share Posted April 3, 2010 What do you exactly want to achieve? You can also just use exception's: try { $do->something(); } catch (ServerMadeBooBoo $e) { echo 'Server made BooBoo.'; exit(0); } catch (UserMadeBooBoo $e) { echo 'You made BooBoo. You bad BooBoo.'; exit(0); } You can also go for the more complex and use a Chain-Of-Responsibility (CoR) pattern: $errorHandler = new ServerMadeBooBoo(new UserMadeBooBoo()); $errorHandler->handle(MY_ERR_CBOOBOO); // Output: You made BooBoo. You bad BooBoo. So what do you exactly want to achieve? Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 3, 2010 Author Share Posted April 3, 2010 okay so I have on index.php function errors($errno, $errstr, $errfile, $errline) { switch ($errno) { case E_TEST_WARNING: echo "<b>DEPRECATED</b> [$errno] $errstr [$errfile on $errline]<br />\n"; break; } return true; } set_error_handler("errors"); trigger_error("IC_00_00_test",E_TEST_WARNING); but this is returning Use of undefined constant E_TEST_WARNING - assumed 'E_TEST_WARNING' any ideas? Quote Link to comment Share on other sites More sharing options...
ignace Posted April 3, 2010 Share Posted April 3, 2010 I told you: you can NOT use custom error constants with built-in functions. You can only replicate this behavior by using your own defined functions: function my_trigger_error($errstr, $errno = MY_ERR_NOTICE) { if (MY_ERR_NOTICE === $errno) { echo 'something'; exit(0); } } //in your code somewhere: my_trigger_error('BooBoo'); Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 3, 2010 Author Share Posted April 3, 2010 according to this I can http://www.weberdev.com/get_example-3917.html Quote Link to comment Share on other sites More sharing options...
ignace Posted April 3, 2010 Share Posted April 3, 2010 Ok if you don't believe me, the PHP manual says: The designated error type for this error. It only works with the E_USER family of constants, and will default to E_USER_NOTICE. -- http://www.php.net/manual/en/function.trigger-error.php Quote Link to comment Share on other sites More sharing options...
hackalive Posted April 3, 2010 Author Share Posted April 3, 2010 I believe you, just want to know ehy the other link says its possible, seems wierd Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.