1use std::io::Error as IoError;
16
17use thiserror::Error;
18
19use crate::pg_server::BoxedError;
20pub type PsqlResult<T> = std::result::Result<T, PsqlError>;
21
22#[derive(Error, Debug)]
24pub enum PsqlError {
25 #[error("Failed to start a new session: {0}")]
26 StartupError(
27 #[source]
28 #[backtrace]
29 BoxedError,
30 ),
31
32 #[error("Invalid password")]
33 PasswordError,
34
35 #[error("Failed to run the query: {0}")]
36 SimpleQueryError(
37 #[source]
38 #[backtrace]
39 BoxedError,
40 ),
41
42 #[error("Failed to prepare the statement: {0}")]
43 ExtendedPrepareError(
44 #[source]
45 #[backtrace]
46 BoxedError,
47 ),
48
49 #[error("Failed to execute the statement: {0}")]
50 ExtendedExecuteError(
51 #[source]
52 #[backtrace]
53 BoxedError,
54 ),
55
56 #[error(transparent)]
57 IoError(#[from] IoError),
58
59 #[error(transparent)]
61 Uncategorized(
62 #[from]
63 #[backtrace]
64 BoxedError,
65 ),
66
67 #[error("Panicked when handling the request: {0}
68This is a bug. We would appreciate a bug report at:
69 https://github.com/risingwavelabs/risingwave/issues/new?labels=type%2Fbug&template=bug_report.yml")]
70 Panic(String),
71
72 #[error("Unable to setup an SSL connection")]
73 SslError(#[from] openssl::ssl::Error),
74
75 #[error("terminating connection due to idle-in-transaction timeout")]
76 IdleInTxnTimeout,
77
78 #[error("Server throttled: {0}")]
79 ServerThrottle(String),
80}
81
82impl PsqlError {
83 pub fn no_statement() -> Self {
84 PsqlError::Uncategorized("No statement found".into())
85 }
86
87 pub fn no_portal() -> Self {
88 PsqlError::Uncategorized("No portal found".into())
89 }
90}