Lnbogen Challenge: refactor exception handling


3/10 at Ellenbogen’s scale.


You have the following code:

   // 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); // *

* 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.