Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop): replace unwrap with error propagation in editor commands

Richie McIlroy8601e08d22f8
diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs
index d42a3ed32..62df2e9cc 100644
--- a/apps/desktop/src-tauri/src/lib.rs
+++ b/apps/desktop/src-tauri/src/lib.rs
@@ -1835,7 +1835,9 @@ struct SerializedEditorInstance {
#[specta::specta]
#[instrument(skip(window))]
async fn create_editor_instance(window: Window) -> Result<SerializedEditorInstance, String> {
- let CapWindowId::Editor { id } = CapWindowId::from_str(window.label()).unwrap() else {
+ let CapWindowId::Editor { id } =
+ CapWindowId::from_str(window.label()).map_err(|e| e.to_string())?
+ else {
return Err("Invalid window".to_string());
};
@@ -1871,7 +1873,9 @@ async fn create_editor_instance(window: Window) -> Result<SerializedEditorInstan
#[specta::specta]
#[instrument(skip(window))]
async fn get_editor_project_path(window: Window) -> Result<PathBuf, String> {
- let CapWindowId::Editor { id } = CapWindowId::from_str(window.label()).unwrap() else {
+ let CapWindowId::Editor { id } =
+ CapWindowId::from_str(window.label()).map_err(|e| e.to_string())?
+ else {
return Err("Invalid window".to_string());
};