Implement IntoError for all generated Errors automatically
This commit is contained in:
parent
8e0014d507
commit
3845f28dad
1 changed files with 15 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
use into::IntoError;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! generate_error_imports {
|
macro_rules! generate_error_imports {
|
||||||
() => {
|
() => {
|
||||||
|
@ -41,6 +43,19 @@ macro_rules! generate_error_types {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IntoError for $kindname {
|
||||||
|
type Target = $name;
|
||||||
|
|
||||||
|
fn into_error(self) -> Self::Target {
|
||||||
|
$name::new(self, None)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn into_error_with_cause(self, cause: Box<Error>) -> Self::Target {
|
||||||
|
$name::new(self, Some(cause))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct $name {
|
pub struct $name {
|
||||||
err_type: $kindname,
|
err_type: $kindname,
|
||||||
|
|
Loading…
Reference in a new issue