diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-11-15 17:09:19 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-15 17:09:19 +0000 |
commit | dee94473c435b38b2d7829731804ac96e6856d9c (patch) | |
tree | 9091efd15222fa8e58ee4b703fd347d989026317 /cli | |
parent | b8cf2599242a9d85d03b57d3649ccdf8bce1530e (diff) |
fix: update message for unsupported schemes with npm and jsr (#26884)
Closes https://github.com/denoland/deno/issues/26596
Diffstat (limited to 'cli')
-rw-r--r-- | cli/file_fetcher.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs index 95d778f0b..640f83c35 100644 --- a/cli/file_fetcher.rs +++ b/cli/file_fetcher.rs @@ -164,8 +164,19 @@ fn get_validated_scheme( ) -> Result<String, AnyError> { let scheme = specifier.scheme(); if !SUPPORTED_SCHEMES.contains(&scheme) { + // NOTE(bartlomieju): this message list additional `npm` and `jsr` schemes, but they should actually be handled + // before `file_fetcher.rs` APIs are even hit. + let mut all_supported_schemes = SUPPORTED_SCHEMES.to_vec(); + all_supported_schemes.extend_from_slice(&["npm", "jsr"]); + all_supported_schemes.sort(); + let scheme_list = all_supported_schemes + .iter() + .map(|scheme| format!(" - \"{}\"", scheme)) + .collect::<Vec<_>>() + .join("\n"); Err(generic_error(format!( - "Unsupported scheme \"{scheme}\" for module \"{specifier}\". Supported schemes: {SUPPORTED_SCHEMES:#?}" + "Unsupported scheme \"{scheme}\" for module \"{specifier}\". Supported schemes:\n{}", + scheme_list ))) } else { Ok(scheme.to_string()) |