• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ExceptionWrapping

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How and why do we use exception wrapping in java? Any sample program would be really helpful.
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jose,

If you are looking for own customized exception for your application. You can extend the respective Exception class and call Super constructors and usally override the methods available in Exception (getCause() and getException() methods).

To your information, all exceptions in Java are extened from java.lang.Exception. For example java.lang.ClassNotFoundException is extended from java.lang.Exception.

Another one, java.sql.BatchUpdateException is extended from java.sql.SQLException and SQLException has java.lang.Exception as its Base class.
 
Shinelin Samuel
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and to your question why use wrapped Exception ?? It is to localize the exception for a specific Code, Application or API. Also, it provides more information about, and helps in identifying, where the exception has occured.
 
reply
    Bookmark Topic Watch Topic
  • New Topic