From 56c3e1787d6191c00b6cfeca2a3f16c2eba93d58 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Fri, 20 Sep 2024 17:52:47 -0300 Subject: [PATCH] added error handling for JSON output --- src/util.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util.rs b/src/util.rs index a3f229e..5aaa11b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,4 +1,4 @@ -use log::error; +use log::{error, info}; use crate::structs::{LoginInfo, LoginPayload, Marker, MarkerPayload}; @@ -49,7 +49,7 @@ pub fn blocking_fetch_auth_token(payload: LoginInfo, api_address: String) -> Str match response_body { Ok(result) => { let csrf_token = result["response"]["user"]["authentication_token"].as_str(); - + info!("Provided JSON: {:?}", result.as_str()); match csrf_token { Some(result) => { return result.to_string(); @@ -63,14 +63,14 @@ pub fn blocking_fetch_auth_token(payload: LoginInfo, api_address: String) -> Str } } Err(error) => { - error!("{}", error); + error!("ERROR: failed to parse the response body to a valid JSON: {}", error); return "ERROR: failed to parse the response body to a valid JSON".to_string(); } } } Err(error) => { - error!("{}", error); + error!("ERROR: failed to fetch the OTS API: {}", error); return "ERROR: failed to fetch the OTS API".to_string(); }