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 ) ) ; } }
Create an exception for the case when an unexpected byte value is read