Your SlideShare is downloading. ×

Effective exceptions

418

Published on

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

No Downloads
Views
Total Views
418
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Writing Effective Exceptions In Java Parag Shah http://www.diycomputerscience.com
  • 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. Exceptions In Java
  • 4. Creating Custom ExceptionsExtend the Exception class for normal exceptionsExtend the RuntimeException class for runtimeexceptionsExtend Error for errorsNever extend ThrowableRedefine all constructors
  • 5. Best Practices - Throwing Using checked vs. unchecked Exception
  • 6. Best Practices - Throwing Throw early catch late
  • 7. GUI Application Data Encountered problem... throw an GUI DataClass Exception Class imediately ! Application ClassHandle theExceptionas late as possible
  • 8. Best Practices - Throwing Throw an appropriate Exception
  • 9. GUI Application Data Encountered problem... throw an GUI DataClass Exception Class imediately ! Application Class Log theexception here
  • 10. Best Practices - Catching Do not suppress Exceptions
  • 11. Best Practices - Catching Do not catch high level Exceptions
  • 12. Best Practices - Catching Cleaning up with finally
  • 13. Best Practices - Catching Log Exceptions only once
  • 14. Best Practices - Catching Catching vs. Propagating
  • 15. Exceptions ResourcesBest practices with Exceptions - http://www.wikijava.org/wiki/10_best_practices_with_Exceptions

×