fix: improve error handling and display in desktop client enrollment flow

Add formatInvokeError helper function to handle various error types from Tauri invoke calls with fallback messages. Update enroll_device to include response body in error message when enrollment fails with non-success status. Add windows_subsystem attribute to main.rs to suppress console window in release builds on Windows.
This commit is contained in:
2026-03-17 19:51:02 +01:00
parent 4a2985ae5e
commit dab7159cc5
3 changed files with 22 additions and 3 deletions

View File

@@ -153,7 +153,12 @@ async fn enroll_device(
.map_err(|err| format!("Enrollment failed: {}", err))?;
if !enroll_response.status().is_success() {
return Err(format!("Enrollment failed with status {}", enroll_response.status()));
let status = enroll_response.status();
let body = enroll_response
.text()
.await
.unwrap_or_else(|_| "<unable to read response body>".into());
return Err(format!("Enrollment failed with status {}: {}", status, body));
}
let enroll = enroll_response

View File

@@ -1,3 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
nexavpn_desktop::run();
}