• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Chain exceptions

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can anybody please tell me what exactly do the chained exceptions used for?
 
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure - if you tell us what chained exceptions are...

You might want to read: ShowSomeEffort
[ February 05, 2008: Message edited by: David Payne ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any non-trivial application is going to have many layers. Some layers may be concerned with the details of interacting with databases, web services, files and so on. Other layers will contain business logic and still others will render the GUI or offer other services.
When an exception occurs in one layer, it may be necessary to propagate that exception to another layer. Since a business logic layer won't know much about working with files/databases/sockets and we want to isolate that layer from the details, we may throw a custom exception (i.e. CustomerNotFoundException) that the business logic can understand and resolve.
However, we will still want to indicate the original cause of the CustomerNotFoundException for debugging purposes, so we create the custom exception with a reference to the original.
It is not unusual to get a chain of dozens of exceptions in J2EE applications because of all the layers in an application server.
 
reply
    Bookmark Topic Watch Topic
  • New Topic