streamly
streamly copied to clipboard
Throw a specific exception in deserialize failure
Currently we just call error:
if (next <= sz)
then Unbox.peekByteIndex off arr >>= \val -> pure (next, val)
else error
$ "deserialize: accessing array at offset = "
++ show (next - 1)
++ " max valid offset = " ++ show (sz - 1)
When we are deserializing we can throw DeserializeUnderflow and when serializing SerializeOverflow. SerializeOverflow can be useful to re-allocate only if we overflow.
Should we do the same for Unbox as well?
Currently, we seldom bound-check. Should we bound check on every deserializeAt and at every serializeAt?