// 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; }