@Override public void error(int reqId, int errorCode, String errorMsg) { try { Object req = openOrdersById.get(reqId); if (req == null) { super.error(reqId, errorCode, errorMsg); return; } OpenOrder openOrder = (OpenOrder) req; String message = errorCode + ": " + errorMsg; lastMessage = message; switch (errorCode) { case 161: // 161: Cancel attempted when order is not in a cancellable // state logger.warn("Received error for {}: {}", openOrder, message); break; case 202: // 202: Order Cancelled break; case 110: // 110: price does not conform to the minimum price variation // for this // contract default: openOrder.setFailed(); openOrdersById.remove(reqId); logger.warn("Received error for {}: {}", openOrder, message); } } catch (Throwable t) { // Do not allow exceptions come back to the socket -- it will cause // disconnects logger.error(t.getMessage(), t); } }