Skip to content

Commit 97795f4

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

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
"opener": patch
3+
---
4+
`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)