Skip to content

Simple crate to simplify creating error types wrapping String

License

Notifications You must be signed in to change notification settings

taitep/string_error_wrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

string_error_wrap

Crate to simplify making error types wrapping String

Useful when a library uses String errors but your app uses something like anyhow.

To use the crate add the crate to the project using cargo (either manually in Cargo.toml or using cargo add string_error_wrap)

Then you can define a new String-wrapping error type like this (replacing Name with what you want the name of the type to be):

string_error_wrap::wrapper_gen!(Name);

This type implements Error, Debug, Clone and From<String>.

It is intended to be used using Result::map_err(YourError::from), which will convert any errors from a String to this type, but may of course also be used in other ways.

About

Simple crate to simplify creating error types wrapping String

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages