1 Replies - 4598 Views - Last Post: 29 June 2012 - 07:15 PM Rate Topic: -----

#1 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Useless try/catch block

Posted 28 May 2012 - 11:39 AM

Just came across this little gem today. Not necessarily a nightmare, but pretty bad nonetheless. It should be noted that it has gone through several revisions where the try/catch was used, but whoever left it like this was having a bad day.


try
{
   // do something
}
catch(SomeException se)
{
    throw se;
}
catch(SomeOtherException soe)
{
    throw soe;
}
catch(Exception e)
{
    throw e;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Useless try/catch block

#2 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 526
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Useless try/catch block

Posted 29 June 2012 - 07:15 PM

This one kind of depends on what is calling this code. Perhaps it was decided that your company wanted the calling object to handle the exception instead. Do you see this kind of action taken elsewhere? I would be wary about changing it before talking with your lead.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1