diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2024-10-15 22:51:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-15 21:51:39 +0000 |
commit | ee904ec06c1a3b3d4e4a87898e777e2f9b587b07 (patch) | |
tree | 87dd34f481c9d35ef9c696599889294269ffff29 /runtime/fmt_errors.rs | |
parent | 3065dadea3792539f050346c534afc0a7821c2b6 (diff) |
fix: add hint for missing `document` global in terminal error (#26218)
This came up on Discord as a question so I thought it's worth adding a
hint for this as it might be a common pitfall.
---------
Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com>
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
Diffstat (limited to 'runtime/fmt_errors.rs')
-rw-r--r-- | runtime/fmt_errors.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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."), + ]), + ]; } } |