Skip to main content

connectorx/sources/oracle/
errors.rs

1use std::string::FromUtf8Error;
2use thiserror::Error;
3
4/// Errors raised by the Oracle source.
5#[derive(Error, Debug)]
6pub enum OracleSourceError {
7    /// Generic ConnectorX error.
8    #[error(transparent)]
9    ConnectorXError(#[from] crate::errors::ConnectorXError),
10
11    /// Error from the `oracle` client.
12    #[error(transparent)]
13    OracleError(#[from] r2d2_oracle::oracle::Error),
14
15    /// Error from the connection pool.
16    #[error(transparent)]
17    OraclePoolError(#[from] r2d2::Error),
18
19    /// The connection string is not a valid URL.
20    #[error(transparent)]
21    OracleUrlError(#[from] url::ParseError),
22
23    /// A percent-encoded part of the connection string is not valid UTF-8.
24    #[error(transparent)]
25    OracleUrlDecodeError(#[from] FromUtf8Error),
26
27    /// A `NUMBER` value could not be converted to a decimal.
28    #[error(transparent)]
29    DecimalError(#[from] rust_decimal::Error),
30
31    /// The query returns a native `BOOLEAN` column, but the loaded Oracle Instant Client
32    /// cannot be trusted to read it.
33    #[error(
34        "column {column} is a native BOOLEAN, but Oracle Instant Client {client} can return \
35         wrong BOOLEAN values without raising an error. Upgrade Instant Client to 23.5 or \
36         later, or convert the column in SQL, e.g. CAST({column} AS NUMBER)"
37    )]
38    UnreliableBooleanClient {
39        /// Name of the first `BOOLEAN` column in the result.
40        column: String,
41        /// Instant Client version reported by `oracle::Version::client()`.
42        client: String,
43    },
44
45    /// Any other errors that are too trivial to be put here explicitly.
46    #[error(transparent)]
47    Other(#[from] anyhow::Error),
48}