c# - Is there a reason to throw an exception twice? -
debugging production code came across had not seen before , not aware of valid purpose. in several methods of 1 of our controllers have try-catch blocks. interesting part there 2 throw statements in 1 of catches.
is there reason have 2 throw statements? if so, in circumstance(s) make sense?
try { //statements } catch (soapexception se) { //log statement return null; } catch (exception ex) { //log statement throw; throw; }
no there no reason throw
twice. second throw
never reached.
it similar having
public int getnumber() { return 1; return 2; // never reached }
update
resharper great tool check things this.
in case grey out second throw
, tell unreachable.
Comments
Post a Comment