Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error coding #485

Closed
khooz opened this issue Dec 21, 2014 · 1 comment
Closed

Error coding #485

khooz opened this issue Dec 21, 2014 · 1 comment

Comments

@khooz
Copy link

khooz commented Dec 21, 2014

Hi! Sorry to bother you again.

This, too, is not an actual bug, but rather a suggestion:
This may be because of me migrated from C/C++ to PHP but, it is good practice that instead of returning false or true, returning an integer (mostly defined as a constant) as the result of a function, mostly 0 for success and not zero as the error code. Then, checking the function is simply

if ($err = myfunc())
{
   switch($err)
   {
      case ERR_CASE_ONE:
      {
         // approperiate action for case one
         break;
      }
      ...
      default:
      {
         // approperiate action for unknown error
         break;
      }
   }
}

And mostly these errors can be masked. For instance you can mask them with PHP's default error level masks like E_ALL and E_WARNING etc. to form a robust error reporting.

@Zizaco
Copy link
Owner

Zizaco commented Jan 31, 2015

Nice. I would accept a pull request regarding this subject.

@Zizaco Zizaco closed this as completed Jan 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants