Trigger
This commit is contained in:
@@ -6,5 +6,6 @@ pub mod pool;
|
||||
pub mod schema;
|
||||
pub mod seriesbychannel;
|
||||
pub mod seriesid;
|
||||
pub mod testerr;
|
||||
|
||||
pub use tokio_postgres as postgres;
|
||||
|
||||
31
dbpg/src/testerr.rs
Normal file
31
dbpg/src/testerr.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use err::thiserror;
|
||||
use err::ThisError;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TestError {
|
||||
msg: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for TestError {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(fmt, "{}", self.msg)
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for TestError {}
|
||||
|
||||
#[derive(Debug, ThisError)]
|
||||
enum Error {
|
||||
Postgres(#[from] tokio_postgres::Error),
|
||||
Dummy(#[from] TestError),
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn err_msg_01() {
|
||||
let err: Error = TestError {
|
||||
msg: "some-error".into(),
|
||||
}
|
||||
.into();
|
||||
assert_eq!(err.to_string(), "Error::Dummy(some-error)")
|
||||
}
|
||||
Reference in New Issue
Block a user