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

Make strings in error types public #425

Closed
wants to merge 1 commit into from
Closed

Conversation

okamt
Copy link

@okamt okamt commented Nov 10, 2024

Synopsis

Can't access strings in error types, useful for mapping to another error type or if you want to change the Display impl

Solution

Make strings in the dedicated error type structs (FromStrError, TryIntoError etc.) public.

Checklist

none are applicable, I think

  • Documentation is updated (if required)
  • Tests are added/updated (if required)
  • CHANGELOG entry is added (if required)

@tyranron
Copy link
Collaborator

@okamt those are private not out of nothing, but for the ability to toss them around without introducing breaking changes to the library API. Could you elaborate more on your use case? Give some example?

@okamt
Copy link
Author

okamt commented Nov 11, 2024

Sure, in my case I have a function that returns something like Result<T, FromStrError>, in the case of a FromStrError I'd like to extract the string that caused the error to put it in a more descriptive/specific error type

@okamt
Copy link
Author

okamt commented Nov 11, 2024

Oh, I just realized the error doesn't store the wrong string at all... lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants