aspose file tools*
The moose likes Struts and the fly likes Calling a method in my exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Calling a method in my exception" Watch "Calling a method in my exception" New topic
Author

Calling a method in my exception

Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
I am trying to call a method that will send an email only when my java app fails. I thought the email part was going to be the hard part... I am getting an error when I try to add method call in catch? See the call to the sendEmail(processName);? Is there some reason why I can't do this?
The error is "unreported exception.MySysException;must be caught or declared to be thrown"? My app will not build. Thanks.



try {
MyExecutor.loadStuff();
} catch (MyAppException e) {
MyLogger.error(
"MyAppException occured in the MyExecutor.loadStuff method", e);
} catch (MySysException e) {
MyLogger.error(
"MySysException occured in the MyExecutor.loadStuff method", e);
sendEmail(args[0]);
}
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 423

You have to write a try-catch-block around this statement.
Katie Doody
Ranch Hand

Joined: Nov 03, 2006
Posts: 90
Ah, that was painless and I feel stupid. Thank you.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Calling a method in my exception