We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 41bcb71 commit 72a7544Copy full SHA for 72a7544
1 file changed
src/error.rs
@@ -25,13 +25,21 @@ macro_rules! make_errors {
25
);
26
27
impl SqlState {
28
- #[doc(hidden)]
+ /// Creates a `SqlState` from its error code.
29
pub fn from_code(s: String) -> SqlState {
30
match STATE_MAP.get(&*s) {
31
Some(state) => state.clone(),
32
None => SqlState::Unknown(s)
33
}
34
35
+
36
+ /// Returns the error code corresponding to the `SqlState`.
37
+ pub fn code(&self) -> &str {
38
+ match *self {
39
+ $(SqlState::$error => $code,)+
40
+ SqlState::Unknown(ref s) => &**s,
41
+ }
42
43
44
)
45
0 commit comments