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 crate::execute;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("failed to execute the query")]
Execute(#[from] execute::Error),
#[error("failed to start new transaction")]
BeginTransaction(#[source] tokio_postgres::Error),
#[error("failed to parse query: {0}")]
Parse(#[from] ParseError),
}
pub type Result<T, E = Error> = std::result::Result<T, E>;
#[derive(Debug, Error)]
pub enum ParseError {
#[error("failed to find binding matching `${binding}`")]
UndefinedBinding { binding: String },
#[error(
"expected an identifier, found '{next}'. Dollar signs may be escaped: `$$`.",
next = found.map(|ch| ch.to_string()).unwrap_or_else(|| "EOF".to_owned())
)]
EmptyIdentifier { found: Option<char> },
}