closes #34 Removed a lot of unwraps, most remaining unwraps will likely stay in the code, as it will be expected behavior to panic and crash rather than a system level abort/exit event
This commit is contained in:
@@ -96,7 +96,13 @@ pub fn pull_policy_exec_histories(
|
||||
exec_types: String,
|
||||
days: i64,
|
||||
) -> Py<PyString> {
|
||||
let rt = tokio::runtime::Runtime::new().unwrap();
|
||||
let rt = match tokio::runtime::Runtime::new() {
|
||||
Ok(rt) => rt,
|
||||
Err(e) => {
|
||||
println!("Failed to build Tokio Runtime: {:?}", e);
|
||||
std::process::abort();
|
||||
}
|
||||
};
|
||||
rt.block_on(async {
|
||||
let _ = init_tracer();
|
||||
});
|
||||
@@ -135,7 +141,13 @@ pub fn pull_policy_exec_histories(
|
||||
},
|
||||
};
|
||||
let data_write = serde_json::to_string_pretty(&data).expect("Failed to serialize");
|
||||
fs::write(writeable_filepath.clone(), data_write).unwrap();
|
||||
match fs::write(writeable_filepath.clone(), data_write) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
println!("Failed to write to: {:?}: {}", &writeable_filepath, e);
|
||||
std::process::abort();
|
||||
}
|
||||
}
|
||||
let mut checkpoint_number: String = skipback(days).to_string();
|
||||
let multi_progress = MultiProgress::new();
|
||||
multi_progress.set_draw_target(ProgressDrawTarget::stdout());
|
||||
@@ -274,7 +286,12 @@ pub fn pull_policy_exec_histories(
|
||||
},
|
||||
};
|
||||
let data_write = serde_json::to_string_pretty(&final_response).unwrap();
|
||||
fs::write(&writeable_filepath, data_write).unwrap();
|
||||
match fs::write(&writeable_filepath, data_write) {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
println!("Failed to write to: {:?}: {}", &writeable_filepath, e);
|
||||
}
|
||||
}
|
||||
if let Some(last_item) = &final_response.response.exechistories.last()
|
||||
&& let Ok(last_date) = NaiveDate::parse_from_str(
|
||||
&last_item.datetime.replace(" +0000 UTC", ""),
|
||||
@@ -289,7 +306,13 @@ pub fn pull_policy_exec_histories(
|
||||
}
|
||||
});
|
||||
progress_bar.finish_with_message("All Checkpoints Complete");
|
||||
let return_data = fs::read_to_string(&writeable_filepath).unwrap();
|
||||
let return_data = match fs::read_to_string(&writeable_filepath) {
|
||||
Ok(return_data) => return_data,
|
||||
Err(e) => {
|
||||
println!("Failed to read data from: {:?}: {}", &writeable_filepath, e);
|
||||
std::process::abort();
|
||||
}
|
||||
};
|
||||
shutdown_tracer_provider();
|
||||
PyString::new(py, &return_data).into()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user