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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Crypto-bank API clients errors.
#![feature(try_trait)]

#[macro_use]
extern crate failure;

extern crate serde_json;

#[macro_use]
extern crate err_convert_macro;
extern crate cxmr_currency;
extern crate cxmr_exchanges;
extern crate cxmr_http_client;

/// HTTP API Client module error type.
#[derive(Debug, Fail)]
pub enum Error {
    /// Option is `None` error.
    #[fail(display = "option none")]
    OptionNone,

    /// Currency module error.
    #[fail(display = "currency module error: {}", _0)]
    Currency(#[cause] cxmr_currency::Error),

    /// Parse int error.
    #[fail(display = "parse int error: {:?}", _0)]
    ParseInt(#[cause] std::num::ParseIntError),

    /// Parse float error.
    #[fail(display = "parse float error: {:?}", _0)]
    ParseFloat(#[cause] std::num::ParseFloatError),

    /// HTTP client error.
    #[fail(display = "http client error: {:?}", _0)]
    Http(#[cause] cxmr_http_client::Error),

    /// Serde JSON error.
    #[fail(display = "serde json error: {:?}", _0)]
    SerdeJson(#[cause] serde_json::Error),

    /// Unexpected order type.
    #[fail(display = "unexpected order type: {}", _0)]
    UnexpectedOrderType(String),

    /// Unexpected order status.
    #[fail(display = "unexpected order status: {}", _0)]
    UnexpectedOrderStatus(String),

    /// Unexpected order time.
    #[fail(display = "unexpected order time: {}", _0)]
    UnexpectedOrderTime(String),

    /// Unexpected order side.
    #[fail(display = "unexpected order side: {}", _0)]
    UnexpectedOrderSide(String),

    /// Unexpected market status.
    #[fail(display = "unexpected market status: {}", _0)]
    UnexpectedMarketStatus(String),

    /// Unexpected rate limit side.
    #[fail(display = "unexpected rate limit side: {}", _0)]
    UnexpectedRateLimitType(String),

    /// Unexpected filter type.
    #[fail(display = "unexpected filter type: {}", _0)]
    UnexpectedFilterType(String),

    /// Exchange not enabled or not found.
    #[fail(display = "exchange client for {:?} is not implemented.", _0)]
    ExchangeNotSupported(cxmr_exchanges::Exchange),
}

err_converter_no_args!(OptionNone, std::option::NoneError);
err_converter!(ParseInt, std::num::ParseIntError);
err_converter!(ParseFloat, std::num::ParseFloatError);
err_converter!(Http, cxmr_http_client::Error);
err_converter!(SerdeJson, serde_json::Error);
err_converter!(Currency, cxmr_currency::Error);