コード例 #1
0
ファイル: RedisConnection.java プロジェクト: 56quarters/baja
  // VisibleForTesting
  RespType verifyResponseType(Set<RespType> expected) {
    final RespType type = IOFunction.runCommand(() -> parser.findType(inputStream));

    if (type == RespType.ERROR) {
      final RespErrResponse err = IOFunction.runCommand(() -> parser.readError(inputStream));
      throw new BajaProtocolErrorException(err.getMessage());
    }

    if (!expected.contains(type)) {
      throw new BajaTypeMismatchException(
          "Unexpected type. Expected one of " + expected + ", got " + type);
    }

    return type;
  }