Level:
3/10 at Ellenbogen's scale.
Preface:
You have the following code:
try{ // Some code which can throw any kind of exception}catch(Exception e){ // If e is from DataGatewayException type – throw the original exception; // Otherwise, wrap the exception with DataGatewayException and throw it. // In any case - this "block" will throw only DataGatewayException. if (!(e is DataGatewayException)) throw WrapAndPublishException(e); // * else throw;}
* WrapAndPublishException method returns a new object from DataGatewayException type (which wraps the original exception).
The Challenge:
Refactor the code above so it will be more readable and extendable(in case we want to re-throw other exception types as well). Use your imagination.
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2009, Oren Ellenbogen
<= Contact me via E-mail
newtelligence dasBlog 2.2.8279.16125