private boolean checkForError(Message message, Response<?> response) {
        if (response.hasError()) {
            int code = response.getError().getCode();
            String data = response.getError().getData();
            String messages = response.getError().getMessage();
            message.setHeader(Web3jConstants.ERROR_CODE, code);
            message.setHeader(Web3jConstants.ERROR_DATA, data);
            message.setHeader(Web3jConstants.ERROR_MESSAGE, messages);
            message.getExchange().setException(new CamelExchangeException(
                    "Web3j failed. Error code: " + code + " data: " + data + " messages: " + messages, message.getExchange()));
            return true;
        } else {
            return false;
        }
    }
@Test
    public void checkForErrorTest() throws Exception {
        Web3ClientVersion response = Mockito.mock(Web3ClientVersion.class);
        Mockito.when(mockWeb3j.web3ClientVersion()).thenReturn(request);
        Mockito.when(request.send()).thenReturn(response);
        Mockito.when(response.hasError()).thenReturn(true);

        Response.Error error = Mockito.mock(Response.Error.class);
        Mockito.when(response.getError()).thenReturn(error);
        Mockito.when(error.getCode()).thenReturn(1);
        Mockito.when(error.getMessage()).thenReturn("error message");
        Mockito.when(error.getData()).thenReturn("error data");

        Exchange exchange = createExchangeWithBodyAndHeader(null, Web3jConstants.ID, Long.valueOf(2));
        template.send(exchange);
        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(Web3jConstants.ERROR_CODE, Integer.class));
        assertEquals("error message", exchange.getIn().getHeader(Web3jConstants.ERROR_MESSAGE, String.class));
        assertEquals("error data", exchange.getIn().getHeader(Web3jConstants.ERROR_DATA, String.class));
    }