Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop circumventing the std definition of FromUtf8Error #412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

1 participant