# TruncatedDataError is raised when IO#readbytes fails to read enough data.
class TruncatedDataError<IOError
def initialize(mesg, data) # :nodoc:
# The read portion of an IO#readbytes attempt.
# Reads exactly +n+ bytes.
# If the data read is nil an EOFError is raised.
# If the data read is too short a TruncatedDataError is raised and the read
# data is obtainable via its #data method.
raise EOFError, "End of file reached"
raise TruncatedDataError.new("data truncated", str)
rescue TruncatedDataError