forked from rojo-rbx/rojo
Graceful errors instead of crashing (#1267)
This commit is contained in:
@@ -255,8 +255,11 @@ pub struct Vfs {
|
||||
|
||||
impl Vfs {
|
||||
/// Creates a new `Vfs` with the default backend, `StdBackend`.
|
||||
pub fn new_default() -> Self {
|
||||
Self::new(StdBackend::new())
|
||||
///
|
||||
/// Returns an error if the filesystem watcher could not be initialized,
|
||||
/// which can happen in restricted or sandboxed environments.
|
||||
pub fn new_default() -> io::Result<Self> {
|
||||
Ok(Self::new(StdBackend::new()?))
|
||||
}
|
||||
|
||||
/// Creates a new `Vfs` with the given backend.
|
||||
@@ -639,7 +642,7 @@ mod test {
|
||||
let file_path = dir.path().join("file.txt");
|
||||
fs_err::write(&file_path, contents.to_string()).unwrap();
|
||||
|
||||
let vfs = Vfs::new(StdBackend::new());
|
||||
let vfs = Vfs::new(StdBackend::new().unwrap());
|
||||
let canonicalized = vfs.canonicalize(&file_path).unwrap();
|
||||
assert_eq!(canonicalized, file_path.canonicalize().unwrap());
|
||||
assert_eq!(
|
||||
@@ -653,7 +656,7 @@ mod test {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let file_path = dir.path().join("test");
|
||||
|
||||
let vfs = Vfs::new(StdBackend::new());
|
||||
let vfs = Vfs::new(StdBackend::new().unwrap());
|
||||
let err = vfs.canonicalize(&file_path).unwrap_err();
|
||||
assert_eq!(err.kind(), io::ErrorKind::NotFound);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user