aspose 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
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: 14157
    
  19

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 7 API documentation
Scala Notes - My blog about Scala
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
 
 
subject: business logic in catch block