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/file_fetcher.rs | |
parent | e83658138bff3605bd37c2b4ae4703081d884729 (diff) |
refactor: reduce number of ErrorKind variants (#3662)
Diffstat (limited to 'cli/file_fetcher.rs')
-rw-r--r-- | cli/file_fetcher.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 03b4a9d02..18c9cbf8a 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -1,5 +1,4 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -use crate::deno_error::too_many_redirects; use crate::deno_error::DenoError; use crate::deno_error::ErrorKind; use crate::deno_error::GetErrorKind; @@ -107,7 +106,7 @@ impl SourceFileFetcher { if !SUPPORTED_URL_SCHEMES.contains(&url.scheme()) { return Err( DenoError::new( - ErrorKind::UnsupportedFetchScheme, + ErrorKind::Other, format!("Unsupported scheme \"{}\" for module \"{}\". Supported schemes: {:#?}", url.scheme(), url, SUPPORTED_URL_SCHEMES), ).into() ); @@ -358,7 +357,8 @@ impl SourceFileFetcher { redirect_limit: i64, ) -> Pin<Box<SourceFileFuture>> { if redirect_limit < 0 { - return futures::future::err(too_many_redirects()).boxed(); + let e = DenoError::new(ErrorKind::Http, "too many redirects".to_string()); + return futures::future::err(e.into()).boxed(); } let is_blacklisted = @@ -1295,7 +1295,7 @@ mod tests { .map(move |result| { assert!(result.is_err()); let err = result.err().unwrap(); - assert_eq!(err.kind(), ErrorKind::TooManyRedirects); + assert_eq!(err.kind(), ErrorKind::Http); }); tokio_util::run(fut); @@ -1571,7 +1571,7 @@ mod tests { SourceFileFetcher::check_if_supported_scheme(&url) .unwrap_err() .kind(), - ErrorKind::UnsupportedFetchScheme + ErrorKind::Other ); } } |