-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherror.rs
More file actions
29 lines (24 loc) · 741 Bytes
/
error.rs
File metadata and controls
29 lines (24 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use core::fmt::Display;
use tokio_postgres::Error;
use crate::Query;
pub enum PoolError {
Creation,
Connection,
}
#[derive(Debug)]
pub enum QueryError<R> {
PreparationFailed(Query<'static>),
HasMoreThanOneRow(/*first_row:*/ R),
ExecuteFailed(Error),
HasNoRow,
}
impl<R> Display for QueryError<R> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::PreparationFailed(_) => write!(f, "failure during the preparation of the query"),
Self::HasMoreThanOneRow(_) => write!(f, "collect more than one result"),
Self::ExecuteFailed(err) => write!(f, "{err}"),
Self::HasNoRow => write!(f, "no row found"),
}
}
}