private J4pException mapException ( Exception pException ) throws J4pException { if ( pException instanceof ConnectException ) { return new J4pConnectException ( "Cannot connect to " + requestHandler . getJ4pServerUrl ( ) + ": " + pException . getMessage ( ) , ( ConnectException ) pException ) ; } else if ( pException instanceof ConnectTimeoutException ) { return new J4pTimeoutException ( "Read timeout while request " + requestHandler . getJ4pServerUrl ( ) + ": " + pException . getMessage ( ) , ( ConnectTimeoutException ) pException ) ; } else if ( pException instanceof IOException ) { return new J4pException ( "IO-Error while contacting the server: " + pException , pException ) ; } else if ( pException instanceof URISyntaxException ) { URISyntaxException sExp = ( URISyntaxException ) pException ; return new J4pException ( "Invalid URI " + sExp . getInput ( ) + ": " + sExp . getReason ( ) , pException ) ; } else { return new J4pException ( "Exception " + pException , pException ) ; } }
Map IO - Exceptions accordingly