use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("Permission denied to execute query")]
QueryRejected,
#[error("{0} statements are not allowed")]
StatementNotAllowed(String),
#[error("Executing {0} function not allowed")]
FunctionNotAllowed(String),
#[error("{0} is not a valid function name")]
InvalidFunctionName(String),
#[error("Invalid query: {0}")]
Parse(String),
}
impl From<libpgquery_sys::Error> for Error {
fn from(error: libpgquery_sys::Error) -> Self {
match error {
libpgquery_sys::Error::Conversion(error) => Self::Parse(error.to_string()),
libpgquery_sys::Error::Decode(error) => Self::Parse(error.to_string()),
libpgquery_sys::Error::Parse(error) => Self::Parse(error),
}
}
}