From c0d64bf7d9c0f2c8ed1d2614745e15bbb3cde6a7 Mon Sep 17 00:00:00 2001 From: Urs de Swardt <52746658+UrsDeSwardt@users.noreply.github.com> Date: Mon, 18 May 2026 15:56:33 +0200 Subject: [PATCH] fix: replace panics with error returns (#3420) * refactor: replace panics with error returns * fix: lints * chore: add changes md --- .changes/positioner-panic.md | 6 ++++++ plugins/positioner/src/ext.rs | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 .changes/positioner-panic.md diff --git a/.changes/positioner-panic.md b/.changes/positioner-panic.md new file mode 100644 index 000000000..deeb7aac0 --- /dev/null +++ b/.changes/positioner-panic.md @@ -0,0 +1,6 @@ +--- +positioner: patch +positioner-js: patch +--- + +Removed panics and replaced them with error handling. \ No newline at end of file diff --git a/plugins/positioner/src/ext.rs b/plugins/positioner/src/ext.rs index b3d405ea2..7c9be8c29 100644 --- a/plugins/positioner/src/ext.rs +++ b/plugins/positioner/src/ext.rs @@ -225,7 +225,9 @@ fn calculate_position( PhysicalPosition { x: tray_x, y } } else { - panic!("Tray position not set"); + return Err(tauri::Error::Io(std::io::Error::other( + "Tray position not set", + ))); } } #[cfg(feature = "tray-icon")] @@ -236,7 +238,9 @@ fn calculate_position( y: tray_y, } } else { - panic!("Tray position not set"); + return Err(tauri::Error::Io(std::io::Error::other( + "Tray position not set", + ))); } } #[cfg(feature = "tray-icon")] @@ -257,7 +261,9 @@ fn calculate_position( y, } } else { - panic!("Tray position not set"); + return Err(tauri::Error::Io(std::io::Error::other( + "Tray position not set", + ))); } } #[cfg(feature = "tray-icon")] @@ -268,7 +274,9 @@ fn calculate_position( y: tray_y, } } else { - panic!("Tray position not set"); + return Err(tauri::Error::Io(std::io::Error::other( + "Tray position not set", + ))); } } #[cfg(feature = "tray-icon")] @@ -287,7 +295,9 @@ fn calculate_position( PhysicalPosition { x, y } } else { - panic!("Tray position not set"); + return Err(tauri::Error::Io(std::io::Error::other( + "Tray position not set", + ))); } } #[cfg(feature = "tray-icon")] @@ -298,7 +308,9 @@ fn calculate_position( y: tray_y, } } else { - panic!("Tray position not set"); + return Err(tauri::Error::Io(std::io::Error::other( + "Tray position not set", + ))); } } };