DEV Community

Sadick
Sadick

Posted on

Don’t Ignore That Error

  • Do not ignore possible errors in your code. Don’t put off handling errors until “later” (you won’t get around to it).

  • Use exceptions well, with discipline. Understand your language’s idioms and requirements for effective exception use.

  • Programmers must be made aware of programmatic errors. Users must be made aware of usage errors.

  • It’s not good enough to log the error (somewhere), and hope that a diligent operator will notice an error and do something about it one day.

  • At every step, consider all of the unusual things that might occur, no matter how unlikely you think they’ll be.

  • Always consider errors that you can recover from, and write appropriate recovery code.

  • Ensure that your error handling is idiomatic, and uses the appropriate language mechanisms.

  • Consider all potential code paths as you write your code. Do not plan to handle “unusual” cases later: you’ll forget and your code will be buggy.

Top comments (0)