Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Handle missing ScreenshotEditor instance gracefully

Richie McIlroy7dd146ad2217
diff --git a/apps/desktop/src-tauri/src/screenshot_editor.rs b/apps/desktop/src-tauri/src/screenshot_editor.rs
index 6971872a9..bdaa468d6 100644
--- a/apps/desktop/src-tauri/src/screenshot_editor.rs
+++ b/apps/desktop/src-tauri/src/screenshot_editor.rs
@@ -59,7 +59,14 @@ impl<'de, R: Runtime> CommandArg<'de, R> for WindowScreenshotEditorInstance {
let instances = window.state::<ScreenshotEditorInstances>();
let instance = futures::executor::block_on(instances.0.read());
- Ok(Self(instance.get(window.label()).cloned().unwrap()))
+ if let Some(instance) = instance.get(window.label()).cloned() {
+ Ok(Self(instance))
+ } else {
+ Err(tauri::InvokeError::from(format!(
+ "no ScreenshotEditor instance for window '{}'",
+ window.label(),
+ )))
+ }
}
}