Expand description
This library makes it easy to handle errors with thiserror.
[dependencies]
tosserror = "0.1"
Example
ⓘ
use thiserror::Error;
use tosserror::Toss;
#[derive(Error, Toss, Debug)]
pub enum DataStoreError {
#[error("invalid value ({value}) encountered")]
InvalidValue {
value: i32,
source: std::num::TryFromIntError,
},
#[error("data store disconnected with msg {msg}: {status}")]
Disconnect{
status: u8,
msg: String,
source: std::io::Error
}
}
// uses
get_value().toss_invalid_value(123)?;
// lazily provide context
data_store_fn().toss_disconnect_with(|| (123, "some msg".to_owned()))?;
See Toss for available attributes.
Derive Macros
- Generates helper traits for enum variants.