Skip to main content

picodata_driver/
error.rs

1use std::io;
2
3/// Details of [`Error::IncompleteBucketMap`].
4#[derive(Debug)]
5#[non_exhaustive]
6pub struct IncompleteBucketMap {
7    /// Tier whose bucket map is incomplete.
8    pub tier: String,
9    /// Number of buckets actually covered by the map.
10    pub covered: u64,
11    /// Number of buckets the tier is configured with.
12    pub expected: u64,
13}
14
15/// Picodata error.
16#[derive(thiserror::Error, Debug)]
17#[non_exhaustive]
18pub enum Error {
19    /// Manager has been closed, no further operations allowed.
20    #[error("manager has been closed")]
21    Closed,
22    /// No online instances available to handle the request.
23    #[error("no online instances available")]
24    Unreachable,
25    /// The instance a query was pinned to is unknown or offline.
26    #[error("instance {0} is not available")]
27    InstanceUnavailable(String),
28    /// A tier's buckets are not fully covered by the topology.
29    #[error(
30        "bucket map for tier {} covers {} of {} buckets",
31        .0.tier, .0.covered, .0.expected
32    )]
33    IncompleteBucketMap(Box<IncompleteBucketMap>),
34    /// Address could not be parsed from returned row.
35    #[error("instance address is invalid: {0}")]
36    InvalidAddress(String),
37    /// Port could not be parsed from returned row.
38    #[error("instance port is invalid")]
39    InvalidPort,
40    /// A UUID could not be parsed from returned row.
41    #[error("uuid is invalid: {0}")]
42    InvalidUuid(#[from] uuid::Error),
43    /// Any error happened within tokio postgres.
44    #[error("postgres protocol error: {0}")]
45    Postgres(#[from] pg::Error),
46    /// Any error happended within deadpool.
47    #[error("postgres pool error: {0}")]
48    PostgresPool(#[from] pgpool::PoolError),
49    /// Any error happened on I/O.
50    #[error("io error: {0}")]
51    IO(#[from] io::Error),
52}