various_rust_utils/api_clients/
errors.rs1use graphql_client::Error;
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ApiCallError {
6 #[error("Request failed: {0}")]
7 RequestFailed(String),
8 #[error("Json parse fail: {0}")]
9 JsonParse(String),
10 #[error("Server returned: {0}")]
11 DataError(String),
12}
13
14pub fn extract_error_message(errors_maybe: Option<Vec<Error>>) -> String {
15 match errors_maybe {
16 None => "Unknown error".to_string(),
17 Some(errors) => {
18 let errors: Vec<String> = errors.iter().map(|e| e.to_string()).collect();
19 errors.join(" | ")
20 }
21 }
22}