diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-01-20 16:50:16 +0100 |
---|---|---|
committer | Ry Dahl <ry@tinyclouds.org> | 2020-01-20 10:50:16 -0500 |
commit | c90036ab88bb1ae6b9c87d5e368f56d8c8afab69 (patch) | |
tree | ebc7b762151489440135c029a1217c80bb810900 /cli/permissions.rs | |
parent | e83658138bff3605bd37c2b4ae4703081d884729 (diff) |
refactor: reduce number of ErrorKind variants (#3662)
Diffstat (limited to 'cli/permissions.rs')
-rw-r--r-- | cli/permissions.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/cli/permissions.rs b/cli/permissions.rs index 4f94fafc6..3964b07a3 100644 --- a/cli/permissions.rs +++ b/cli/permissions.rs @@ -1,5 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::deno_error::{permission_denied_msg, type_error}; +use crate::deno_error::{other_error, permission_denied_msg}; use crate::flags::DenoFlags; use ansi_term::Style; #[cfg(not(test))] @@ -179,8 +179,7 @@ impl DenoPermissions { } let url: &str = url.unwrap(); // If url is invalid, then throw a TypeError. - let parsed = Url::parse(url) - .map_err(|_| type_error(format!("Invalid url: {}", url)))?; + let parsed = Url::parse(url).map_err(ErrBox::from)?; Ok( self.get_state_net(&format!("{}", parsed.host().unwrap()), parsed.port()), ) @@ -289,7 +288,7 @@ impl DenoPermissions { "env" => Ok(self.allow_env), "plugin" => Ok(self.allow_plugin), "hrtime" => Ok(self.allow_hrtime), - n => Err(type_error(format!("No such permission name: {}", n))), + n => Err(other_error(format!("No such permission name: {}", n))), } } } |