File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes business logic in catch block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "business logic in catch block" Watch "business logic in catch block" New topic
Author

business logic in catch block

abhishek roy
Ranch Hand

Joined: Jun 08, 2006
Posts: 78
Hi,
I m having a dillema now. I have a java program that tries to send message accross an http server. Now when the server is not available, it throws an obvious IOException. Now my requirement is that I want to resend the same message to a backup http server if the first server fails.

I have found the solution but I think my code smells.

the client code :


Can anybody tell me what is wrong with this code??


regards,<br />Abhishek
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

You could structure it a little bit better. Nesting all that code in subsequent catch blocks looks a bit messy. For example:



Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
abhishek roy
Ranch Hand

Joined: Jun 08, 2006
Posts: 78
Thanks a lot Jesper. That indeed looks clean to me. Thanks again for your help.
regards,
Abhishek
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: business logic in catch block