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 std::string::FromUtf8Error;
use thiserror::Error;
use toml::{de, ser};

pub mod fs;
pub mod model;
#[cfg(feature = "server")]
pub mod server;

/// Error type for wsvc
#[derive(Error, Debug)]
pub enum WsvcError {
    #[error("fs error: {0}")]
    FsError(#[from] fs::WsvcFsError),
    #[error("codec error: {0}")]
    CodecError(#[from] FromUtf8Error),
    #[error("bad usage: {0}")]
    BadUsage(String),
    #[error("repo error: {0}")]
    RepoError(String),
    #[error("config deserialize failed: {0}")]
    ConfigDeserializeFailed(#[from] de::Error),
    #[error("config serialize failed: {0}")]
    ConfigSerializeFailed(#[from] ser::Error),
    #[error("lack of config: {0}\n\ntips: {1}")]
    LackOfConfig(String, String),
    #[error("need configuring: {0}")]
    NeedConfiguring(String),
    #[error("Serialization error: {0}")]
    SerializationError(#[from] serde_json::Error),
    #[cfg(feature = "cli")]
    #[error("network error: {0}")]
    NetworkError(#[from] tokio_tungstenite::tungstenite::Error),
    #[error("data error: {0}")]
    DataError(String),
    #[error("repo without record")]
    EmptyRepoError,
}