protected ByteBuffer handleBinaryException(Object key, RequestReader request, ByteBuffer response,
      String operation, Exception e) {
    getLogger().info("Exception occurred while processing " + operation + " :" + key, e);
    String errStr = e.getMessage() == null ? "SERVER ERROR" : e.getMessage();
    byte[] errMsg = errStr.getBytes(asciiCharset);
    int responseLength = HEADER_LENGTH + errMsg.length;
    if (response.capacity() < responseLength) {
      response = request.getResponse(responseLength);
    }
    response.limit(responseLength);
    response.putShort(POSITION_RESPONSE_STATUS, ResponseStatus.INTERNAL_ERROR.asShort());
    response.putInt(TOTAL_BODY_LENGTH_INDEX, errMsg.length);
    response.position(HEADER_LENGTH);
    response.put(errMsg);
    return response;
  }
Used to handle exceptions thrown by the region callbacks.
geode-memcached/src/main/java/org/apache/geode/internal/memcached/commands/AbstractCommand.java