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 Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/ 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). Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036350 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 Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036354 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. Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036363 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? Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036367 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? Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036373 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? Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036384 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'); Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036395 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 Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036415 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 Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036422 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 Link to comment https://forums.phpfreaks.com/topic/197449-error-cases/#findComment-1036423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.