summaryrefslogtreecommitdiff
path: root/cli/global_state.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-02-23 14:51:29 -0500
committerGitHub <noreply@github.com>2020-02-23 14:51:29 -0500
commit4e1abb4f3a1fbdac25b1e7db0588572e4d5a6579 (patch)
tree644ace7dc1acac7b09bfab037e0ca589fa11987b /cli/global_state.rs
parent45eb2f9b37c2c7498c58eb45f76667aaa4a7d731 (diff)
refactor: use OpError instead of ErrBox for errors in ops (#4058)
To better reflect changes in error types in JS from #3662 this PR changes default error type used in ops from "ErrBox" to "OpError". "OpError" is a type that can be sent over to JSON; it has all information needed to construct error in JavaScript. That made "GetErrorKind" trait useless and so it was removed altogether. To provide compatibility with previous use of "ErrBox" an implementation of "From<ErrBox> for OpError" was added, however, it is an escape hatch and ops implementors should strive to use "OpError" directly.
Diffstat (limited to 'cli/global_state.rs')
-rw-r--r--cli/global_state.rs57
1 files changed, 0 insertions, 57 deletions
diff --git a/cli/global_state.rs b/cli/global_state.rs
index 9880f18a2..8bf68c225 100644
--- a/cli/global_state.rs
+++ b/cli/global_state.rs
@@ -6,7 +6,6 @@ use crate::compilers::TargetLib;
use crate::compilers::TsCompiler;
use crate::compilers::WasmCompiler;
use crate::deno_dir;
-use crate::deno_error::permission_denied;
use crate::file_fetcher::SourceFileFetcher;
use crate::flags;
use crate::http_cache;
@@ -18,8 +17,6 @@ use deno_core::ModuleSpecifier;
use std;
use std::env;
use std::ops::Deref;
-use std::path::Path;
-use std::str;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
use std::sync::Mutex;
@@ -172,60 +169,6 @@ impl GlobalState {
Ok(compiled_module)
}
- #[inline]
- pub fn check_read(&self, filename: &Path) -> Result<(), ErrBox> {
- self.permissions.check_read(filename)
- }
-
- #[inline]
- pub fn check_write(&self, filename: &Path) -> Result<(), ErrBox> {
- self.permissions.check_write(filename)
- }
-
- #[inline]
- pub fn check_env(&self) -> Result<(), ErrBox> {
- self.permissions.check_env()
- }
-
- #[inline]
- pub fn check_net(&self, hostname: &str, port: u16) -> Result<(), ErrBox> {
- self.permissions.check_net(hostname, port)
- }
-
- #[inline]
- pub fn check_net_url(&self, url: &url::Url) -> Result<(), ErrBox> {
- self.permissions.check_net_url(url)
- }
-
- #[inline]
- pub fn check_run(&self) -> Result<(), ErrBox> {
- self.permissions.check_run()
- }
-
- pub fn check_dyn_import(
- &self,
- module_specifier: &ModuleSpecifier,
- ) -> Result<(), ErrBox> {
- let u = module_specifier.as_url();
- match u.scheme() {
- "http" | "https" => {
- self.check_net_url(u)?;
- Ok(())
- }
- "file" => {
- let filename = u
- .to_file_path()
- .unwrap()
- .into_os_string()
- .into_string()
- .unwrap();
- self.check_read(Path::new(&filename))?;
- Ok(())
- }
- _ => Err(permission_denied()),
- }
- }
-
#[cfg(test)]
pub fn mock(argv: Vec<String>) -> GlobalState {
GlobalState::new(flags::DenoFlags {