From 23dec8e96f972c855444367bb5afa8a3b5164a78 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Sun, 2 Jun 2024 11:53:35 -0700 Subject: [PATCH] Better invalid URL errors --- src-tauri/src/http_request.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/http_request.rs b/src-tauri/src/http_request.rs index d260eb26..23d25fb3 100644 --- a/src-tauri/src/http_request.rs +++ b/src-tauri/src/http_request.rs @@ -89,14 +89,24 @@ pub async fn send_http_request( let uri = match http::Uri::from_str(url_string.as_str()) { Ok(u) => u, Err(e) => { - return response_err(response, e.to_string(), window).await; + return response_err( + response, + format!("Failed to parse URL \"{}\": {}", url_string, e.to_string()), + window, + ) + .await; } }; // Yes, we're parsing both URI and URL because they could return different errors let url = match Url::from_str(uri.to_string().as_str()) { Ok(u) => u, Err(e) => { - return response_err(response, e.to_string(), window).await; + return response_err( + response, + format!("Failed to parse URL \"{}\": {}", url_string, e.to_string()), + window, + ) + .await; } };