forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.rs
More file actions
49 lines (38 loc) · 1.03 KB
/
Copy patherror.rs
File metadata and controls
49 lines (38 loc) · 1.03 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
// Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
use std::io;
pub type Result<T> = std::result::Result<T, CliError>;
#[derive(thiserror::Error, Debug)]
pub enum CliError {
#[error("Unknown error: {0}")]
Unknown(String),
#[error("IO error: {0}")]
Io(io::Error),
#[error("Script error: {0}")]
Script(run_script::ScriptError),
#[error("Http error: {0}")]
Http(Box<ureq::Error>),
#[error("Serde error: {0}")]
Serde(Box<serde_json::Error>),
}
impl From<io::Error> for CliError {
fn from(err: io::Error) -> CliError {
CliError::Io(err)
}
}
impl From<run_script::ScriptError> for CliError {
fn from(err: run_script::ScriptError) -> CliError {
CliError::Script(err)
}
}
impl From<ureq::Error> for CliError {
fn from(err: ureq::Error) -> CliError {
CliError::Http(Box::new(err))
}
}
impl From<serde_json::Error> for CliError {
fn from(err: serde_json::Error) -> CliError {
CliError::Serde(Box::new(err))
}
}