diff --git a/crates/drag/src/lib.rs b/crates/drag/src/lib.rs index f075449..aee2aa9 100644 --- a/crates/drag/src/lib.rs +++ b/crates/drag/src/lib.rs @@ -93,6 +93,8 @@ pub enum Error { UnsupportedWindowHandle, #[error("failed to start drag")] FailedToStartDrag, + #[error("drag image not found")] + ImageNotFound, #[cfg(target_os = "linux")] #[error("empty drag target list")] EmptyTargetList, diff --git a/crates/drag/src/platform_impl/macos/mod.rs b/crates/drag/src/platform_impl/macos/mod.rs index da5271a..fe09f8a 100644 --- a/crates/drag/src/platform_impl/macos/mod.rs +++ b/crates/drag/src/platform_impl/macos/mod.rs @@ -46,6 +46,9 @@ pub fn start_drag( let img: id = msg_send![class!(NSImage), alloc]; let img: id = match image { Image::File(path) => { + if !path.exists() { + return Err(crate::Error::ImageNotFound); + } NSImage::initByReferencingFile_(img, new_nsstring(&path.to_string_lossy())) } Image::Raw(bytes) => {