diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-08-26 00:22:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-26 00:22:15 +0200 |
commit | 9bfb0df805719cb3f022a5b5d9f9d898ae954c2e (patch) | |
tree | 6c7d62d95fcbde54ebbe1035bdc74618c63cfbc0 /cli/module_graph.rs | |
parent | d0ccab7fb7dd80030d3765ca9a9af44de6ecda5a (diff) |
refactor: remove OpError, use ErrBox everywhere (#7187)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/module_graph.rs')
-rw-r--r-- | cli/module_graph.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/cli/module_graph.rs b/cli/module_graph.rs index 5b15c0cd4..7cbd4cfcc 100644 --- a/cli/module_graph.rs +++ b/cli/module_graph.rs @@ -5,7 +5,6 @@ use crate::file_fetcher::SourceFile; use crate::file_fetcher::SourceFileFetcher; use crate::import_map::ImportMap; use crate::msg::MediaType; -use crate::op_error::OpError; use crate::permissions::Permissions; use crate::swc_util::Location; use crate::tsc::pre_process_file; @@ -37,7 +36,7 @@ fn err_with_location(e: ErrBox, maybe_location: Option<&Location>) -> ErrBox { location.filename, location.line ); let err_str = e.to_string(); - OpError::other(format!("{}{}", err_str, location_str)).into() + ErrBox::error(format!("{}{}", err_str, location_str)) } else { e } @@ -52,10 +51,10 @@ fn validate_no_downgrade( if let Some(referrer) = maybe_referrer.as_ref() { if let "https" = referrer.as_url().scheme() { if let "http" = module_specifier.as_url().scheme() { - let e = OpError::permission_denied( - "Modules loaded over https:// are not allowed to import modules over http://".to_string() + let e = ErrBox::new("PermissionDenied", + "Modules loaded over https:// are not allowed to import modules over http://" ); - return Err(err_with_location(e.into(), maybe_location)); + return Err(err_with_location(e, maybe_location)); }; }; }; @@ -77,10 +76,10 @@ fn validate_no_file_from_remote( match specifier_url.scheme() { "http" | "https" => {} _ => { - let e = OpError::permission_denied( + let e = ErrBox::new("PermissionDenied", "Remote modules are not allowed to statically import local modules. Use dynamic import instead.".to_string() ); - return Err(err_with_location(e.into(), maybe_location)); + return Err(err_with_location(e, maybe_location)); } } } |