• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

fabioDMFerreira / rust-events-oriented-arch / 6341660898

28 Sep 2023 04:28PM UTC coverage: 35.579% (+0.9%) from 34.699%
6341660898

push

github

fabioDMFerreira
lint: fix issue on news_websocket_processor

1 of 1 new or added line in 1 file covered. (100.0%)

3127 of 8789 relevant lines covered (35.58%)

22.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.76
/utils/src/error.rs
1
use actix::MailboxError;
2
use serde::Serialize;
3

4
pub const DATABASE_ERROR_CODE: u32 = 1;
5
pub const BROKER_ERROR_CODE: u32 = 2;
6
pub const HTTP_ERROR_CODE: u32 = 3;
7
pub const AUTH_TOKEN_ENCODING_CODE: u32 = 4;
22✔
8
pub const WS_ERROR_CODE: u32 = 5;
22✔
9
pub const SERIALIZATION_ERROR_CODE: u32 = 6;
11✔
10

22✔
11
#[derive(Debug, Serialize, Clone, PartialEq)]
35✔
12
pub struct CommonError {
13
    pub message: String,
12✔
14
    pub code: u32,
12✔
15
}
×
16

×
17
impl CommonError {
×
18
    pub fn new(message: &str) -> Self {
×
19
        CommonError {
22✔
20
            message: message.to_string(),
46✔
21
            code: 0,
11✔
22
        }
23✔
23
    }
×
24
}
25

6✔
26
impl std::fmt::Display for CommonError {
12✔
27
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14✔
28
        write!(f, "Error: {}, Code: {}", self.message, self.code)
8✔
29
    }
2✔
30
}
6✔
31

6✔
32
#[derive(Debug, Clone)]
48✔
33
pub struct DatabaseError {
2✔
34
    pub message: String,
26✔
35
}
1✔
36

1✔
37
impl DatabaseError {
38
    pub fn new(message: &str) -> Self {
2✔
39
        DatabaseError {
3✔
40
            message: message.to_string(),
4✔
41
        }
2✔
42
    }
3✔
43
}
44

1✔
45
impl From<DatabaseError> for CommonError {
1✔
46
    fn from(val: DatabaseError) -> Self {
8✔
47
        Self {
8✔
48
            message: val.message,
8✔
49
            code: DATABASE_ERROR_CODE,
×
50
        }
×
51
    }
8✔
52
}
53

×
54
#[derive(Debug, Clone)]
2✔
55
pub struct BrokerError {
×
56
    pub message: String,
1✔
57
}
58

×
59
impl BrokerError {
×
60
    pub fn new(message: &str) -> Self {
×
61
        BrokerError {
×
62
            message: message.to_string(),
×
63
        }
64
    }
×
65
}
66

67
impl From<BrokerError> for CommonError {
68
    fn from(val: BrokerError) -> Self {
1✔
69
        CommonError {
1✔
70
            message: val.message,
1✔
71
            code: BROKER_ERROR_CODE,
72
        }
73
    }
1✔
74
}
75

76
#[derive(Debug, Clone)]
×
77
pub struct HttpError {
78
    pub message: String,
×
79
}
80

81
impl HttpError {
82
    pub fn new(message: &str) -> Self {
×
83
        HttpError {
×
84
            message: message.to_string(),
×
85
        }
86
    }
×
87
}
88

89
impl From<HttpError> for CommonError {
90
    fn from(val: HttpError) -> Self {
×
91
        CommonError {
×
92
            message: val.message,
×
93
            code: HTTP_ERROR_CODE,
94
        }
95
    }
×
96
}
97

98
impl From<MailboxError> for CommonError {
99
    fn from(val: MailboxError) -> Self {
×
100
        CommonError {
×
101
            message: val.to_string(),
×
102
            code: WS_ERROR_CODE,
103
        }
104
    }
×
105
}
106

107
#[derive(Debug, Clone)]
×
108
pub struct SerializationError {
109
    pub message: String,
×
110
}
111

112
impl SerializationError {
113
    pub fn new(message: &str) -> Self {
1✔
114
        SerializationError {
1✔
115
            message: message.to_string(),
1✔
116
        }
117
    }
1✔
118
}
119

120
impl From<SerializationError> for CommonError {
121
    fn from(val: SerializationError) -> Self {
1✔
122
        CommonError {
1✔
123
            message: val.message,
1✔
124
            code: SERIALIZATION_ERROR_CODE,
125
        }
126
    }
1✔
127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc