• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling a method in my exception

 
Katie Doody
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 433
Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to write a try-catch-block around this statement.
 
Katie Doody
Ranch Hand
Posts: 90
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, that was painless and I feel stupid. Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic