Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

business logic in catch block  RSS feed

 
abhishek roy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could structure it a little bit better. Nesting all that code in subsequent catch blocks looks a bit messy. For example:

 
abhishek roy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot Jesper. That indeed looks clean to me. Thanks again for your help.
regards,
Abhishek
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!