Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Checked application exception

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Application exceptions that are checked exceptions
may be defined as such by being listed in the throws clauses of the methods of the bean�s business
interface.

Does it mean that an Exception may be a Application exception for a business method and a system exception for an other one, for example :




Is my example true?

Thanks for help.

[ August 11, 2008: Message edited by: Alexandre Fradin ]
[ August 11, 2008: Message edited by: Alexandre Fradin ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


// here an application exception
// there a system exception


Your example is not that great, as you're throwing the same exception System exceptions are not application exceptions. There are three patterns :
  • Application exceptions that are checked exceptions may be defined as such by being listed in the throws clauses of the methods.
  • An application exception that is an unchecked exception is defined as an application exception by annotating it with the ApplicationException metadata annotation, or denoting it in the deployment descriptor with the application-exception element.
  • A system exception is an exception that is a java.rmi.RemoteException (or one of its subclasses) or a RuntimeException that is not an application exception.


  • Your example uses a checked exception (extending Exception), so it has to be defined in the throws clause of the method. Here is another example, with two application exceptions, one checked and one unchecked :

     
    Alexandre Fradin
    Greenhorn
    Posts: 11
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ok thank you Christophe.

    I missed the third point... So in my example, MyException is an application exception for both m1() and m2().
     
    Christophe Verré
    Sheriff
    Posts: 14691
    16
    Eclipse IDE VI Editor Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Yes, a checked application exception.
     
    Did you miss me? Did you miss this tiny ad?
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic