summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNayeem Rahman <muhammed.9939@gmail.com>2020-02-12 16:02:34 +0000
committerGitHub <noreply@github.com>2020-02-12 17:02:34 +0100
commit3563ab4c53689480ac47871fe928ae7c78a2fcc3 (patch)
tree3bd9cc6a2fd8cce245bd4decba2c6ee16003208c
parente6167c78134182c45689bda7bcb12af05009349c (diff)
fix: Correctly determine a --cached-only error (#3979)
-rw-r--r--cli/file_fetcher.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs
index 1fabe7e96..18d78c514 100644
--- a/cli/file_fetcher.rs
+++ b/cli/file_fetcher.rs
@@ -205,18 +205,20 @@ impl SourceFileFetcher {
} else {
"".to_owned()
};
- let err = if err_kind == ErrorKind::NotFound {
+ // Hack: Check error message for "--cached-only" because the kind
+ // conflicts with other errors.
+ let err = if err.to_string().contains("--cached-only") {
let msg = format!(
- r#"Cannot resolve module "{}"{}"#,
+ r#"Cannot find module "{}"{} in cache, --cached-only is specified"#,
module_url, referrer_suffix
);
DenoError::new(ErrorKind::NotFound, msg).into()
- } else if err_kind == ErrorKind::PermissionDenied {
+ } else if err_kind == ErrorKind::NotFound {
let msg = format!(
- r#"Cannot find module "{}"{} in cache, --cached-only is specified"#,
+ r#"Cannot resolve module "{}"{}"#,
module_url, referrer_suffix
);
- DenoError::new(ErrorKind::PermissionDenied, msg).into()
+ DenoError::new(ErrorKind::NotFound, msg).into()
} else {
err
};
@@ -427,9 +429,9 @@ impl SourceFileFetcher {
// We can't fetch remote file - bail out
return futures::future::err(
std::io::Error::new(
- std::io::ErrorKind::PermissionDenied,
+ std::io::ErrorKind::NotFound,
format!(
- "cannot find remote file '{}' in cache",
+ "Cannot find remote file '{}' in cache, --cached-only is specified",
module_url.to_string()
),
)
@@ -1449,7 +1451,7 @@ mod tests {
.await;
assert!(result.is_err());
let err = result.err().unwrap();
- assert_eq!(err.kind(), ErrorKind::PermissionDenied);
+ assert_eq!(err.kind(), ErrorKind::NotFound);
// download and cache file
let result = fetcher_1