You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(error): record byte offset on decode and encode error variants
Reshapes the position-aware error approach per #1266 review feedback. Moves
position metadata out of the foundational `ironrdp-error` crate and onto the
decode and encode `*ErrorKind` enum variants where it actually applies.
Previously this PR added an optional `ErrorPosition { offset, field }` slot
to `Error<Kind>`'s `ErrorMeta`, paying a metadata slot on every error in the
workspace to serve only the decode and encode surfaces. The new shape places
a non-optional `offset: usize` on each variant that can know one:
- `DecodeErrorKind::{NotEnoughBytes, InvalidField, UnexpectedMessageType,
UnsupportedVersion, UnsupportedValue}` gain `offset: usize`
- `EncodeErrorKind::*` mirrors the same shape for encode-side errors
- `*::Other` is unchanged; producers of `Other` typically lack stream-cursor
access and the variant exists precisely for those cases
The `in_field` dotted-path use case is dropped from this PR per the same
review: `Error::set_context` already covers it. No parallel structured
field-tracking channel is introduced.
Trait and macro changes:
- `NotEnoughBytesErr`, `InvalidFieldErr`, `UnexpectedMessageTypeErr`,
`UnsupportedVersionErr`, `UnsupportedValueErr` all take an additional
`offset: usize` parameter
- The five corresponding `*_err!` macros gain `at:` and `in:` prefixes for
explicit offset and cursor-extracted offset respectively
- `OtherErr` and `other_err!` are unchanged
- `cast_length!` and `cast_int!` macros pass `0` to the new offset slot
(the macros do not have stream-cursor access)
Call-site migration:
- All 84 affected files updated to pass an explicit offset
- Most existing call sites pass `0` (the documented "offset unknown" sentinel)
since the cursor is not always in lexical scope at the call site
- Cursor-aware sites can opt in via the new `in: cursor` macro syntax
- A workspace sweep upgrading `at: 0` to `in: cursor` where applicable is a
follow-up
Display output includes the offset when known:
`invalid \`field\` at offset 47: reason`
Refs #1257, #1120. Supersedes the cross-cutting `ErrorPosition` approach
that was on this branch before today's review.
0 commit comments