JelteF / derive_more

Some more derive(Trait) options
MIT License
1.74k stars 123 forks source link

Make strings in error types public #425

Closed okamt closed 1 week ago

okamt commented 1 week ago

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

tyranron commented 1 week ago

@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 commented 1 week ago

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 commented 1 week ago

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