mirror of
https://github.com/dtolnay/thiserror.git
synced 2025-04-05 22:07:37 +03:00
Add test for optional backtrace
This commit is contained in:
parent
fac0a7aa0d
commit
d9ed0fba49
1 changed files with 85 additions and 23 deletions
|
@ -4,23 +4,54 @@
|
||||||
use std::backtrace::Backtrace;
|
use std::backtrace::Backtrace;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
pub mod structs {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
#[error("...")]
|
#[error("...")]
|
||||||
pub struct OptSourceNoBacktraceStruct {
|
pub struct OptSourceNoBacktrace {
|
||||||
#[source]
|
#[source]
|
||||||
source: Option<anyhow::Error>,
|
source: Option<anyhow::Error>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
#[error("...")]
|
#[error("...")]
|
||||||
pub struct OptSourceAlwaysBacktraceStruct {
|
pub struct OptSourceAlwaysBacktrace {
|
||||||
#[source]
|
#[source]
|
||||||
source: Option<anyhow::Error>,
|
source: Option<anyhow::Error>,
|
||||||
backtrace: Backtrace,
|
backtrace: Backtrace,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum OptSourceNoBacktraceEnum {
|
#[error("...")]
|
||||||
|
pub struct NoSourceOptBacktrace {
|
||||||
|
#[backtrace]
|
||||||
|
backtrace: Option<Backtrace>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
#[error("...")]
|
||||||
|
pub struct AlwaysSourceOptBacktrace {
|
||||||
|
source: anyhow::Error,
|
||||||
|
#[backtrace]
|
||||||
|
backtrace: Option<Backtrace>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
#[error("...")]
|
||||||
|
pub struct OptSourceOptBacktrace {
|
||||||
|
#[source]
|
||||||
|
source: Option<anyhow::Error>,
|
||||||
|
#[backtrace]
|
||||||
|
backtrace: Option<Backtrace>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod enums {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum OptSourceNoBacktrace {
|
||||||
#[error("...")]
|
#[error("...")]
|
||||||
Test {
|
Test {
|
||||||
#[source]
|
#[source]
|
||||||
|
@ -29,7 +60,7 @@ pub enum OptSourceNoBacktraceEnum {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum OptSourceAlwaysBacktraceEnum {
|
pub enum OptSourceAlwaysBacktrace {
|
||||||
#[error("...")]
|
#[error("...")]
|
||||||
Test {
|
Test {
|
||||||
#[source]
|
#[source]
|
||||||
|
@ -37,3 +68,34 @@ pub enum OptSourceAlwaysBacktraceEnum {
|
||||||
backtrace: Backtrace,
|
backtrace: Backtrace,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum NoSourceOptBacktrace {
|
||||||
|
#[error("...")]
|
||||||
|
Test {
|
||||||
|
#[backtrace]
|
||||||
|
backtrace: Option<Backtrace>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum AlwaysSourceOptBacktrace {
|
||||||
|
#[error("...")]
|
||||||
|
Test {
|
||||||
|
source: anyhow::Error,
|
||||||
|
#[backtrace]
|
||||||
|
backtrace: Option<Backtrace>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub enum OptSourceOptBacktrace {
|
||||||
|
#[error("...")]
|
||||||
|
Test {
|
||||||
|
#[source]
|
||||||
|
source: Option<anyhow::Error>,
|
||||||
|
#[backtrace]
|
||||||
|
backtrace: Option<Backtrace>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue