This commit is contained in:
Dominik Werder
2023-09-01 16:51:08 +02:00
parent 7f75639e18
commit 488a681d0d
5 changed files with 41 additions and 6 deletions

View File

@@ -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
View 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)")
}