File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ async fn fetch_history() -> Option<String> {
177
177
return None ;
178
178
}
179
179
let val = current_state_lab_raw. unwrap ( ) ;
180
- let parsed_resp: Vec < UserHistoryFetch > = val. json :: < Vec < UserHistoryFetch > > ( ) . await . unwrap ( ) ;
180
+ let parsed_resp: Vec < UserHistoryFetch > = val. json :: < Vec < UserHistoryFetch > > ( ) . await . unwrap_or ( Vec :: new ( ) ) ;
181
181
182
182
let first_user = parsed_resp. first ( ) ;
183
183
if first_user. is_none ( ) {
@@ -212,7 +212,13 @@ async fn fetching_state_loop(pool: &Pool<DbConnectionType>) {
212
212
let current_state_lab_raw = reqwest:: get ( get_lab_state_endpoint) . await ;
213
213
let mut current_state_lab_id: bool = false ;
214
214
if let Ok ( data) = current_state_lab_raw {
215
- let current_state_lab: LabState = data. json ( ) . await . unwrap ( ) ;
215
+ let current_state_lab: LabState = match data. json ( ) . await {
216
+ Ok ( data) => data,
217
+ Err ( err) => {
218
+ log:: error!( "Error parsing json: {:?}" , err) ;
219
+ return ;
220
+ }
221
+ }
216
222
log:: info!( "Current state 1: {:?}" , current_state_lab) ;
217
223
current_state_lab_id = current_state_lab. id == 1 ; //Casting int to bool
218
224
}
You can’t perform that action at this time.
0 commit comments