summaryrefslogtreecommitdiff
path: root/cli/fs.rs
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2019-07-11 00:53:48 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-07-11 14:37:00 -0400
commitabe8a113ad8004f160eac5f3f115cb28c5072ba7 (patch)
tree099b2b019bd7b5d1689cfa5b4bef3ceded10c59d /cli/fs.rs
parentdb5c66a638d399d5ebb2832bb7b52e8f76ced49d (diff)
Refactor error to use dynamic dispatch and traits
This is in preperation for dynamic import (#1789), which is more easily implemented when errors are dynamic.
Diffstat (limited to 'cli/fs.rs')
-rw-r--r--cli/fs.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/cli/fs.rs b/cli/fs.rs
index 3b5709804..6fe891141 100644
--- a/cli/fs.rs
+++ b/cli/fs.rs
@@ -5,6 +5,7 @@ use std::io::ErrorKind;
use std::io::Write;
use std::path::{Path, PathBuf};
+use deno::ErrBox;
use rand;
use rand::Rng;
@@ -15,8 +16,6 @@ use std::os::unix::fs::DirBuilderExt;
#[cfg(any(unix))]
use std::os::unix::fs::PermissionsExt;
-use crate::deno_error::DenoResult;
-
pub fn write_file<T: AsRef<[u8]>>(
filename: &Path,
data: T,
@@ -114,18 +113,16 @@ pub fn normalize_path(path: &Path) -> String {
}
#[cfg(unix)]
-pub fn chown(path: &str, uid: u32, gid: u32) -> DenoResult<()> {
- use crate::deno_error::DenoError;
+pub fn chown(path: &str, uid: u32, gid: u32) -> Result<(), ErrBox> {
let nix_uid = Uid::from_raw(uid);
let nix_gid = Gid::from_raw(gid);
unix_chown(path, Option::Some(nix_uid), Option::Some(nix_gid))
- .map_err(DenoError::from)
+ .map_err(ErrBox::from)
}
#[cfg(not(unix))]
-pub fn chown(_path: &str, _uid: u32, _gid: u32) -> DenoResult<()> {
+pub fn chown(_path: &str, _uid: u32, _gid: u32) -> Result<(), ErrBox> {
// Noop
// TODO: implement chown for Windows
- use crate::deno_error;
- Err(deno_error::op_not_implemented())
+ Err(crate::deno_error::op_not_implemented())
}