summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/Cargo.toml1
-rw-r--r--runtime/fmt_errors.rs11
2 files changed, 12 insertions, 0 deletions
diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml
index ba9dc6243..6cb00a97e 100644
--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -100,6 +100,7 @@ deno_websocket.workspace = true
deno_webstorage.workspace = true
node_resolver = { workspace = true, features = ["sync"] }
+color-print.workspace = true
dlopen2.workspace = true
encoding_rs.workspace = true
fastwebsockets.workspace = true
diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs
index 0d4274e8a..2d9d09a29 100644
--- a/runtime/fmt_errors.rs
+++ b/runtime/fmt_errors.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
//! This mod provides DenoError to unify errors across Deno.
+use color_print::cstr;
use deno_core::error::format_frame;
use deno_core::error::JsError;
use deno_terminal::colors::cyan;
@@ -367,6 +368,16 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
]
)
];
+ } else if msg.contains("document is not defined") {
+ return vec![
+ FixSuggestion::info(cstr!(
+ "<u>document</> global is not available in Deno."
+ )),
+ FixSuggestion::hint_multiline(&[
+ cstr!("Use a library like <u>happy-dom</>, <u>deno_dom</>, <u>linkedom</> or <u>JSDom</>"),
+ cstr!("and setup the <u>document</> global according to the library documentation."),
+ ]),
+ ];
}
}