toasty_core/error/invalid_driver_configuration.rs
1use super::Error;
2
3/// Error when a driver's capability configuration is invalid or inconsistent.
4///
5/// This occurs when:
6/// - Driver capability flags are inconsistent (e.g., native_varchar=true but varchar type not specified)
7/// - Required capability fields are missing or contradictory
8///
9/// These errors indicate a programming error in the driver implementation itself,
10/// not a user error or runtime condition.
11#[derive(Debug)]
12pub(super) struct InvalidDriverConfiguration {
13 message: Box<str>,
14}
15
16impl std::error::Error for InvalidDriverConfiguration {}
17
18impl core::fmt::Display for InvalidDriverConfiguration {
19 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
20 write!(f, "invalid driver configuration: {}", self.message)
21 }
22}
23
24impl Error {
25 /// Creates an invalid driver configuration error.
26 ///
27 /// This is used when a driver's capability configuration is invalid or inconsistent.
28 /// These errors indicate a bug in the driver implementation.
29 pub fn invalid_driver_configuration(message: impl Into<String>) -> Error {
30 Error::from(super::ErrorKind::InvalidDriverConfiguration(
31 InvalidDriverConfiguration {
32 message: message.into().into(),
33 },
34 ))
35 }
36
37 /// Returns `true` if this error is an invalid driver configuration error.
38 pub fn is_invalid_driver_configuration(&self) -> bool {
39 matches!(self.kind(), super::ErrorKind::InvalidDriverConfiguration(_))
40 }
41}