virtual-labs-archive / problem-solving-iiith

Other
4 stars 437 forks source link

Exception and Error Handling #1150

Open madhavipuliraju opened 5 years ago

madhavipuliraju commented 5 years ago

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