| Crates.io | gevi_error |
| lib.rs | gevi_error |
| version | 1.0.0 |
| created_at | 2025-11-14 13:57:27.573136+00 |
| updated_at | 2025-11-14 13:57:27.573136+00 |
| description | A flavor of error types and error handling that I like |
| homepage | https://gitlab.com/d5b4b2/gevi_error |
| repository | https://gitlab.com/d5b4b2/gevi_error |
| max_upload_size | |
| id | 1932899 |
| size | 12,325 |
A flavor of error types and error handling that I like.
Use error! to scaffold your error who will be called Error.
use ::std::path::Path;
::gevi_error::error! {
ReadFile(()),
Http(u64),
}
impl Error {
pub(crate) fn read_file<T>(path: T, error: ::std::io::Error) -> Self where T: AsRef<Path> {
Error::ReadFile(
Inner {
message: format!("Failed to read from {}", path.as_ref().display()),
cause: Some(Box::new(error)),
},
()
)
}
pub(crate) fn http(code: u64) -> Self {
Error::Http(
Inner {
message: format!("Server responded with code {code}"),
cause: None,
},
code
)
}
}
Wrap the main function to print the error trace when the program errors.
fn main() -> ::std::process::ExitCode {
Error::wrap(try_main)
}
fn try_main() -> Result<(), Error> {
// Your code
Ok(())
}