Effective exceptions

680 views

Published on

Published in: Technology, News & Politics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
680
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
6
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Effective exceptions

  1. 1. Writing Effective Exceptions In Java Parag Shah http://www.diycomputerscience.com
  2. 2. Exceptions In JavaWhat were the old ways of error handling ?http://rlc.vlinder.ca/blog/2010/01/error-handling-in-c/What are Exceptions ?Why should we use them ?
  3. 3. Exceptions In Java
  4. 4. Creating Custom ExceptionsExtend the Exception class for normal exceptionsExtend the RuntimeException class for runtimeexceptionsExtend Error for errorsNever extend ThrowableRedefine all constructors
  5. 5. Best Practices - Throwing Using checked vs. unchecked Exception
  6. 6. Best Practices - Throwing Throw early catch late
  7. 7. GUI Application Data Encountered problem... throw an GUI DataClass Exception Class imediately ! Application ClassHandle theExceptionas late as possible
  8. 8. Best Practices - Throwing Throw an appropriate Exception
  9. 9. GUI Application Data Encountered problem... throw an GUI DataClass Exception Class imediately ! Application Class Log theexception here
  10. 10. Best Practices - Catching Do not suppress Exceptions
  11. 11. Best Practices - Catching Do not catch high level Exceptions
  12. 12. Best Practices - Catching Cleaning up with finally
  13. 13. Best Practices - Catching Log Exceptions only once
  14. 14. Best Practices - Catching Catching vs. Propagating
  15. 15. Exceptions ResourcesBest practices with Exceptions - http://www.wikijava.org/wiki/10_best_practices_with_Exceptions

×