Skip to content

Commit 350fe5a

Browse files
committed
fix(opener): return error if path not exists
1 parent 1fe70dc commit 350fe5a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"opener": patch
3+
"opener-js": patch
4+
---
5+
`open_path` now returns an error if the file does not exist

plugins/opener/src/open.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ pub fn open_url<P: AsRef<str>, S: AsRef<str>>(url: P, with: Option<S>) -> crate:
5353
/// ```
5454
pub fn open_path<P: AsRef<Path>, S: AsRef<str>>(path: P, with: Option<S>) -> crate::Result<()> {
5555
let path = path.as_ref();
56+
// Returns an IO error if not exists, and besides `exists()` is a shorthand for `metadata()`
57+
_ = path.metadata()?;
5658
open(path, with)
5759
}

0 commit comments

Comments
 (0)