forked from RedisJSON/RedisJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.rs
38 lines (32 loc) · 750 Bytes
/
error.rs
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
use jsonpath_lib::JsonPathError;
#[derive(Debug)]
pub struct Error {
pub msg: String,
}
impl From<String> for Error {
fn from(e: String) -> Self {
Error { msg: e }
}
}
impl From<&str> for Error {
fn from(e: &str) -> Self {
Error { msg: e.to_string() }
}
}
impl From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Self {
Error { msg: e.to_string() }
}
}
impl From<JsonPathError> for Error {
fn from(e: JsonPathError) -> Self {
Error {
msg: format!("JSON Path error: {:?}", e).replace("\n", "\\n"),
}
}
}
impl From<Error> for redis_module::RedisError {
fn from(e: Error) -> Self {
redis_module::RedisError::String(e.msg)
}
}