virtual-labs-archive/problem-solving-iiith

Exception and Error Handling

Opened this issue · 0 comments

Please find the best practices for handling and creating exceptions.

  1. Use try/catch/finally blocks to recover from errors or release resources
  2. Handle common conditions without throwing exceptions
  3. Design classes so that exceptions can be avoided
  4. Throw exceptions instead of returning an error code
  5. Use the predefined exception types
  6. Use grammatically correct error messages
  7. In custom exceptions, provide additional properties as needed
  8. Restore state when methods don't complete due to exceptions