From abe8a113ad8004f160eac5f3f115cb28c5072ba7 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 11 Jul 2019 00:53:48 +0200 Subject: 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. --- cli/fs.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'cli/fs.rs') 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>( 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()) } -- cgit v1.2.3