@@ -0,0 +1,1180 @@
+package com.gistlabs.mechanize.exceptions;%0A%0Aimport java.io.IOException;%0Aimport java.io.UnsupportedEncodingException;%0A%0Aimport org.apache.http.client.ClientProtocolException;%0A%0A/**%0A * Factory for creating mechanize exception warping existing exceptions and also creating new exceptions.%0A * @author Martin Kersten %3CMartin.Kersten.mk@gmail.com%3E%0A */%0Apublic class MechanizeExceptionFactory %7B%0A%09%0A%09public static MechanizeException newException(Exception cause) %7B%0A%09%09if(cause instanceof ClientProtocolException) %0A%09%09%09return new MechanizeClientProtocolException(cause);%0A%09%09else if(cause instanceof IOException)%0A%09%09%09return new MechanizeIOException(cause);%0A%09%09else if(cause instanceof UnsupportedEncodingException)%0A%09%09%09return new MechanizeUnsupportedEncodingException(cause);%0A%09%09else if(cause instanceof URISyntaxException)%0A%09%09%09return new MechanizeURISyntaxException(cause);%0A%09%09else %0A%09%09%09return new MechanizeException(cause);%0A%09%7D%0A%09%0A%09public static MechanizeInitializationException newInitializationException(Exception cause) %7B%0A%09%09return new MechanizeInitializationException(cause);%0A%09%7D%0A%0A%09public static MechanizeException newMechanizeException(String message) %7B%0A%09%09return new MechanizeException(message);%0A%09%7D%0A%7D%0A

Introduce MechanizeExceptionFactory to avoid dealing with special mechanize exceptions and factor out the wrap and creation logic