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:
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
fn main() {
|
||||
nexavpn_desktop::run();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user