/** * Create an exception for the case when an unexpected byte value is read * * @param expected * @param b * @return * @throws MessageFormatException */ private static MessagePackException unexpected(String expected, byte b) { MessageFormat format = MessageFormat.valueOf(b); if (format == MessageFormat.NEVER_USED) { return new MessageNeverUsedFormatException(String.format("Expected %s, but encountered 0xC1 \"NEVER_USED\" byte", expected)); } else { String name = format.getValueType().name(); String typeName = name.substring(0, 1) + name.substring(1).toLowerCase(); return new MessageTypeException(String.format("Expected %s, but got %s (%02x)", expected, typeName, b)); } }
throw new MessageNeverUsedFormatException("Unknown value type");
break; case NEVER_USED: throw new MessageNeverUsedFormatException("Encountered 0xC1 \"NEVER_USED\" byte");