Skip to content

Commit a3ae37a

Browse files
committed
feat: error dialog on attach error
1 parent 4864236 commit a3ae37a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/gui/usbipd_gui.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,18 @@ impl UsbipdGui {
201201
for (menu_item, device) in menu_items.iter() {
202202
if handle == menu_item.handle {
203203
if device.is_attached() {
204+
// Silently ignore errors here, as the device may have been unplugged
205+
// which will have detached it
204206
device.detach().ok();
205207
} else {
206-
device.attach().ok();
208+
device.attach().map_err(|e| {
209+
nwg::modal_error_message(
210+
rc_self.window.handle,
211+
"WSL USB Manager: Attach Error",
212+
format!("Could not attach device, is it still plugged in?\n\n{}", e)
213+
.as_str(),
214+
);
215+
}).ok();
207216
}
208217
}
209218
}

0 commit comments

Comments
 (0)