1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use crate::protocol::parts::execution_result::ExecutionResult;
use crate::protocol::parts::server_error::ServerError;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum HdbError {
#[error("Error occured in deserialization.")]
Deserialization {
#[from]
source: serde_db::de::DeserializationError,
},
#[error("Error occured in serialization.")]
Serialization {
#[from]
source: serde_db::ser::SerializationError,
},
#[error("Some error occured while decoding CESU-8.")]
Cesu8 {
#[from]
source: cesu8::Cesu8DecodingError,
},
#[error("Erroneous Connection Parameters")]
ConnParams {
source: Box<dyn std::error::Error>,
},
#[error("Database server responded with an error.")]
DbError {
#[from]
source: ServerError,
},
#[error("Error occured while evaluating a HdbResponse or an HdbReturnValue.")]
Evaluation(&'static str),
#[error("Database server responded with at least one error.")]
ExecutionResults(Vec<ExecutionResult>),
#[error("Error occured while streaming a LOB.")]
LobStreaming(std::io::Error),
#[error("Implementation error: {}", _0)]
Impl(&'static str),
#[error("Implementation error: {}", _0)]
ImplDetailed(String),
#[error("Error occured in thread synchronization.")]
Poison,
#[error("An error occurred on the server that requires the session to be terminated.")]
SessionClosingTransactionError,
#[error("Error occured in communication with the database")]
Tcp {
#[from]
source: std::io::Error,
},
#[error("Wrong usage: {}", _0)]
Usage(&'static str),
#[error("Wrong usage: {}", _0)]
UsageDetailed(String),
}
pub type HdbResult<T> = std::result::Result<T, HdbError>;
impl HdbError {
pub fn server_error(&self) -> Option<&ServerError> {
match self {
Self::DbError {
source: server_error,
} => Some(&server_error),
_ => None,
}
}
pub(crate) fn conn_params(error: Box<dyn std::error::Error>) -> Self {
Self::ConnParams { source: error }
}
}
impl<G> From<std::sync::PoisonError<G>> for HdbError {
fn from(_error: std::sync::PoisonError<G>) -> Self {
Self::Poison
}
}