summaryrefslogtreecommitdiff
path: root/ext/node/errors.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/errors.rs')
-rw-r--r--ext/node/errors.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/ext/node/errors.rs b/ext/node/errors.rs
index 929f51e1b..b489cb937 100644
--- a/ext/node/errors.rs
+++ b/ext/node/errors.rs
@@ -1,5 +1,7 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
+use std::path::PathBuf;
+
use deno_core::error::generic_error;
use deno_core::error::type_error;
use deno_core::error::AnyError;
@@ -61,13 +63,26 @@ pub fn err_invalid_package_target(
) -> AnyError {
let rel_error = !is_import && !target.is_empty() && !target.starts_with("./");
let mut msg = "[ERR_INVALID_PACKAGE_TARGET]".to_string();
+ let pkg_json_path = PathBuf::from(pkg_path).join("package.json");
if key == "." {
assert!(!is_import);
- msg = format!("{} Invalid \"exports\" main target {} defined in the package config {}package.json", msg, target, pkg_path)
+ msg = format!(
+ "{} Invalid \"exports\" main target {} defined in the package config {}",
+ msg,
+ target,
+ pkg_json_path.display()
+ )
} else {
let ie = if is_import { "imports" } else { "exports" };
- msg = format!("{} Invalid \"{}\" target {} defined for '{}' in the package config {}package.json", msg, ie, target, key, pkg_path)
+ msg = format!(
+ "{} Invalid \"{}\" target {} defined for '{}' in the package config {}",
+ msg,
+ ie,
+ target,
+ key,
+ pkg_json_path.display()
+ )
};
if let Some(base) = maybe_referrer {