Fix UnexpectedError for non-integer length/offset
Fix `UnexpectedError` for non-integer length/offset and raise `InvalidParameterError` instead.
Fix UnexpectedError for non-integer length/offset: Fix `UnexpectedError` for non-integer length/offset and raise `InvalidParameterError` instead.