mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
refactor: cleanup Node compatibility code (#15766)
- move errors related to Node compat from cli/node/errors.rs to "ext/node" crate - remove dependency on "node_resolver" crate - make some of structures private to the "cli/node" module
This commit is contained in:
parent
16dbf4adc3
commit
264ad49e18
6 changed files with 32 additions and 75 deletions
|
@ -3,6 +3,7 @@
|
|||
use deno_core::error::generic_error;
|
||||
use deno_core::error::type_error;
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::url::Url;
|
||||
|
||||
pub fn err_invalid_module_specifier(
|
||||
request: &str,
|
||||
|
@ -120,3 +121,23 @@ pub fn err_package_import_not_defined(
|
|||
|
||||
type_error(msg)
|
||||
}
|
||||
|
||||
pub fn err_unsupported_dir_import(path: &str, base: &str) -> AnyError {
|
||||
generic_error(format!("[ERR_UNSUPPORTED_DIR_IMPORT] Directory import '{}' is not supported resolving ES modules imported from {}", path, base))
|
||||
}
|
||||
|
||||
pub fn err_unsupported_esm_url_scheme(url: &Url) -> AnyError {
|
||||
let mut msg =
|
||||
"[ERR_UNSUPPORTED_ESM_URL_SCHEME] Only file and data URLS are supported by the default ESM loader"
|
||||
.to_string();
|
||||
|
||||
if cfg!(window) && url.scheme().len() == 2 {
|
||||
msg = format!(
|
||||
"{}. On Windows, absolute path must be valid file:// URLs",
|
||||
msg
|
||||
);
|
||||
}
|
||||
|
||||
msg = format!("{}. Received protocol '{}'", msg, url.scheme());
|
||||
generic_error(msg)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue