class InvalidChainIdHashHandler extends ComparableFailoverHandler {

  @Override
  public <T> Response<T> handle(final Invocation<T> invocation, final Response<T> response) {
    try {
      logger.debug("Handle {} with {}", response.getError(), this);

      if (null == response.getError() || !(response.getError() instanceof CommitException)) {
        return response;
      }

      // FIXME: no other way to handle it?
      final CommitException commitException = (CommitException) response.getError();
      if (!commitException.getMessage().contains("invalid chain id hash")) {
        return response;
      }

      final Context current = ContextHolder.current();
      logger.trace("Context: {}", current);
      final ChainIdHashHolder chainIdHashHolder = current.get(GRPC_VALUE_CHAIN_ID_HASH_HOLDER);
      if (null == chainIdHashHolder) {
        throw new HerajException("No chain id hash holder in context");
      }

      final RequestMethod<BlockchainStatus> requestMethod = blockchainMethods.getBlockchainStatus();
      final ChainIdHash chainIdHash = requestMethod.invoke().getChainIdHash();
      logger.debug("Fetched ChainIdHash: {}", chainIdHash);
      chainIdHashHolder.put(chainIdHash);
    } catch (HerajException e) {
      throw e;
    } catch (Exception e) {
      throw new HerajException("Unexpected error", e);
    }

    Response<T> next;
    try {
      final T ret = invocation.invoke();
      next = Response.success(ret);
    } catch (Exception e) {
      next = Response.fail(e);
    }
    return next;
  }

    InvalidChainIdHashHandler();

}