• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Exception cast in Java

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a simple web application(No Struts or Spring), lets say i am getting an exception in the business layer and i want that to be sent to the UI layer for some reasons.
How can this be acheived? I have heard something like exception cast in Java. I googled for this,but i was not able to get the required informaton.
Can anyone please let me know the details?

Cheers
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure what you mean by exception cast. The easiest way to get an exception from the business layer to the UI is just to throw it (or not catch it) - it will bubble up until you handle it, and if you only handle it in the UI that's where it will end up.

One thing that's quite common (and that might be what you're looking for) is when you want the business layer to throw a particular special type of exception so the UI doesn't have to know about the internal workings. Then you can catch a general exception, wrap it in your special one, and throw that. The pattern looks something like this:

reply
    Bookmark Topic Watch Topic
  • New Topic