-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
52 lines (47 loc) · 1.21 KB
/
Copy patherror.rs
File metadata and controls
52 lines (47 loc) · 1.21 KB
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
mod details;
mod kind;
mod write_type;
pub use details::*;
pub use kind::*;
use thiserror::Error;
pub use write_type::*;
#[derive(Debug, Error)]
#[error("{0}", .message)]
pub struct DriverError {
/// The category of the error.
pub kind: DriverErrorKind,
/// The error message.
pub message: String,
/// The error details available for server errors only.
pub details: Option<DriverErrorDetails>,
}
impl DriverError {
/// Creates a new driver error.
pub fn new<T>(
kind: DriverErrorKind,
message: T,
details: Option<DriverErrorDetails>,
) -> Self
where
T: Into<String>,
{
Self {
kind,
message: message.into(),
details,
}
}
/// Creates a new driver error with the given category, message, and no
/// details.
pub(crate) fn with_message<T>(kind: DriverErrorKind, message: T) -> Self
where
T: Into<String>,
{
Self::new(kind, message, None)
}
/// Creates a new driver error with the given category, standard message,
/// and no details.
pub(crate) fn with_kind(kind: DriverErrorKind) -> Self {
Self::with_message(kind, kind.to_string())
}
}