sqlx_core_oldapi/odbc/
error.rs1use crate::error::DatabaseError;
2use odbc_api::Error as OdbcApiError;
3use std::borrow::Cow;
4use std::fmt::{Display, Formatter, Result as FmtResult};
5
6#[derive(Debug)]
7pub struct OdbcDatabaseError(pub OdbcApiError);
8
9impl Display for OdbcDatabaseError {
10 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
11 Display::fmt(&self.0, f)
12 }
13}
14
15impl std::error::Error for OdbcDatabaseError {}
16
17impl DatabaseError for OdbcDatabaseError {
18 fn message(&self) -> &str {
19 "ODBC error"
20 }
21 fn code(&self) -> Option<Cow<'_, str>> {
22 None
23 }
24 fn as_error(&self) -> &(dyn std::error::Error + Send + Sync + 'static) {
25 self
26 }
27 fn as_error_mut(&mut self) -> &mut (dyn std::error::Error + Send + Sync + 'static) {
28 self
29 }
30 fn into_error(self: Box<Self>) -> Box<dyn std::error::Error + Send + Sync + 'static> {
31 self
32 }
33}
34
35impl From<OdbcApiError> for crate::error::Error {
36 fn from(value: OdbcApiError) -> Self {
37 crate::error::Error::Database(Box::new(OdbcDatabaseError(value)))
38 }
39}