Skip to content

Conversation

MarijnS95
Copy link
Contributor

By already taking the Vec<u8> out of this error we leave users no choice to bubble up the error with typical ? or anyhow::Context::context(), because vec<u8> does not implement std::error::Error (it's not an error after all).

Instead of trying to outsmart the standard library and annoying the user, return the original FromUtf8Error as it is, leaving the caller to deal with it however they please (i.e. bubble it up, or call into_bytes() themselves if they wish to continue parsing it otherwise).

@MarijnS95 MarijnS95 force-pushed the give-users-FromUtf8Error branch from b6a04c1 to 9d0369f Compare February 5, 2025 12:45
By already taking the `Vec<u8>` out of this error we leave
users no choice to bubble up the error with typical `?` or
`anyhow::Context::context()`, because `vec<u8>` does not implement
`std::error::Error` (it's not an error after all).

Instead of trying to outsmart the standard library and annoying the
user, return the original `FromUtf8Error` *as it is*, leaving the
caller to deal with it however they please (i.e. bubble it up, or
call `into_bytes()` themselves if they wish to continue parsing it
otherwise).
@MarijnS95 MarijnS95 force-pushed the give-users-FromUtf8Error branch from 9d0369f to 62d18df Compare February 5, 2025 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants