@Override
    public BackgroundException map(final IOException failure) {
        final StringBuilder buffer = new StringBuilder();
        this.append(buffer, failure.getMessage());
        if(failure instanceof SMB1NotSupportedException) {
            return new UnsupportedException(buffer.toString(), failure);
        }
        for(Throwable cause : ExceptionUtils.getThrowableList(failure)) {
            if(cause instanceof SMBRuntimeException) {
                return new SMBExceptionMappingService().map((SMBRuntimeException) cause);
            }
        }
        return new ConnectionRefusedException(buffer.toString(), failure);
    }
@Test
    public void map() {
        {
            final BackgroundException f = new SMBTransportExceptionMappingService().map(
                    new TransportException(new ExecutionException(new SMBRuntimeException(new TimeoutException("Timeout expired")))));
            assertEquals("Connection failed", f.getMessage());
            assertEquals(ConnectionTimeoutException.class, f.getClass());
        }
        {
            final BackgroundException f = new SMBTransportExceptionMappingService().map(new TransportException(new ExecutionException(new SMBRuntimeException(new TimeoutException("Timeout expired")))));
            assertEquals("Timeout expired. The connection attempt timed out. The server may be down, or your network may not be properly configured.",
                    f.getDetail());
            assertEquals(ConnectionTimeoutException.class, f.getClass());
        }
        // com.hierynomus.smbj.common.SMBRuntimeException: com.hierynomus.protocol.transport.TransportException: java.io.EOFException: EOF while reading packet
        {
            final BackgroundException f = new SMBTransportExceptionMappingService().map(new TransportException(new EOFException("EOF while reading packet")));
            assertEquals(ConnectionRefusedException.class, f.getClass());
        }
    }