diff --git a/tokio-postgres/src/error/mod.rs b/tokio-postgres/src/error/mod.rs index 75664d258..28345d30a 100644 --- a/tokio-postgres/src/error/mod.rs +++ b/tokio-postgres/src/error/mod.rs @@ -337,14 +337,20 @@ pub enum ErrorPosition { }, } -#[derive(Debug, PartialEq)] -enum Kind { +/// Error kind returned by the database. +#[allow(missing_docs)] +#[derive(Debug, PartialEq, Clone)] +pub enum Kind { Io, UnexpectedMessage, Tls, ToSql(usize), FromSql(usize), + /// A column was fetched from the row which wasn't returned by the database. + /// This usually indicates the column wasn't included in the query. Column(String), + /// The number of parameters expected by the query doesn't match the number + /// of parameters passed when executing the prepared statement. Parameters(usize, usize), Closed, Db, @@ -438,6 +444,11 @@ impl Error { self.as_db_error().map(DbError::code) } + /// Returns the kind of error. + pub fn kind(&self) -> &Kind { + &self.0.kind + } + fn new(kind: Kind, cause: Option>) -> Error { Error(Box::new(ErrorInner { kind, cause })) }