Skip to content

Commit b2c8fc8

Browse files
committed
fix: change to description error messages parsing config file
1 parent e71a22c commit b2c8fc8

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

primitives/src/config.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ use toml;
66

77
lazy_static! {
88
static ref DEVELOPMENT_CONFIG: Config =
9-
toml::from_str(include_str!("../../docs/config/dev.toml")).unwrap();
9+
toml::from_str(include_str!("../../docs/config/dev.toml"))
10+
.expect("Failed to parse dev.toml config file");
1011
static ref PRODUCTION_CONFIG: Config =
11-
toml::from_str(include_str!("../../docs/config/prod.toml")).unwrap();
12+
toml::from_str(include_str!("../../docs/config/prod.toml"))
13+
.expect("Failed to parse prod.toml config file");
1214
}
1315

1416
#[derive(Serialize, Deserialize, Debug, Clone)]

validator_worker/src/sentry_interface.rs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,11 @@ impl<T: Adapter + 'static> SentryApi<T> {
7070
pub fn propagate(&self, messages: Vec<MessageTypes>) {
7171
let serialised_messages: Vec<String> = messages
7272
.into_iter()
73-
.map(|message| match message {
74-
MessageTypes::NewState(new_state) => serde_json::to_string(&new_state).unwrap(),
75-
MessageTypes::ApproveState(approve_state) => {
76-
serde_json::to_string(&approve_state).unwrap()
77-
}
78-
MessageTypes::Heartbeat(heartbeat) => serde_json::to_string(&heartbeat).unwrap(),
79-
MessageTypes::RejectState(reject_state) => {
80-
serde_json::to_string(&reject_state).unwrap()
81-
}
82-
MessageTypes::Accounting(accounting) => serde_json::to_string(&accounting).unwrap(),
83-
})
73+
.map(|message| serde_json::to_string(&message).unwrap())
8474
.collect();
8575

8676
for validator in self.channel.spec.validators.into_iter() {
87-
let auth_token = self.adapter.get_auth(&validator).unwrap();
77+
let auth_token = self.adapter.get_auth(&validator).expect("Failed to get user auth token");
8878
match propagate_to(
8979
&auth_token,
9080
self.config.propagation_timeout,
@@ -157,7 +147,7 @@ impl<T: Adapter + 'static> SentryApi<T> {
157147
.validators
158148
.into_iter()
159149
.find(|&v| v.id == whoami);
160-
let auth_token = self.adapter.get_auth(validator.unwrap()).unwrap();
150+
let auth_token = self.adapter.get_auth(validator.unwrap()).expect("Failed to get user auth token");
161151

162152
let url = format!(
163153
"{}/events-aggregates?after={}",
@@ -167,7 +157,7 @@ impl<T: Adapter + 'static> SentryApi<T> {
167157
let future = self
168158
.client
169159
.get(&url)
170-
.header("authorization", auth_token.to_string())
160+
.header(AUTHORIZATION, auth_token.to_string())
171161
.send()
172162
.and_then(|mut res: Response| res.json::<EventAggregateResponse>());
173163

@@ -228,7 +218,7 @@ pub async fn all_channels(
228218
) -> Result<Vec<Channel>, ()> {
229219
let validator = adapter.whoami();
230220
let url = sentry_url.to_owned();
231-
let first_page = await!(fetch_page(url.clone(), 0, validator.clone())).unwrap();
221+
let first_page = await!(fetch_page(url.clone(), 0, validator.clone())).expect("Failed to get channels from sentry url");
232222
if first_page.total_pages < 2 {
233223
Ok(first_page.channels)
234224
} else {

0 commit comments

Comments
 (0)