all bits considered data to information to knowledge


10 Commandments of Error Handling

  1. No method shall return “success/failure” code.
  2. All methods shall return results (“void” where appropriate
  3. All operations that could potentially result in an exception must be organized into
    [try…catch…finally] blocks in the method’s body
  4. An exception should be thrown to the caller in case of a run-time error
  5. An exception must be specific to the error, no generic exception should be raised (and if
    necessary, they should be wrapped into actionable exceptions of specific type)
  6. All exceptions must be logged
  7. Exception only should be caught if they are of specific type, and could be handled in a
    meaningful way.
  8. Any exception that could be potentially thrown by a method must be documented in that
  9. Any exception not caught at the top caller level must be logged, and consider fatal. Normally,
    this would result in termination of the execution, though it should be dealt on case by case
  10. Use Error Handling and Logging Frameworks


Microsoft Error Handling Guidelines for C#

Three Rules for Effective Exception Handling in Java

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.