protected IOException toIoException ( Exception e ) { if ( e instanceof IOException ) { return ( IOException ) e ; } else { return new IOException ( "Unexpected failure" , e ) ; } }
This Exception conversion needs to return the IOException instead of throwing it this is so that the compiler can detect that for the final Exception check something is actually thrown .