mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(repl): do not panic when Deno.inspect throws (#11292)
This commit is contained in:
parent
7edb1d713c
commit
78ac19f51f
2 changed files with 28 additions and 1 deletions
|
@ -611,3 +611,24 @@ fn assign_underscore_error() {
|
|||
));
|
||||
assert!(err.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn custom_inspect() {
|
||||
let (out, err) = util::run_and_collect_output(
|
||||
true,
|
||||
"repl",
|
||||
Some(vec![
|
||||
r#"const o = {
|
||||
[Symbol.for("Deno.customInspect")]() {
|
||||
throw new Error('Oops custom inspect error');
|
||||
},
|
||||
};"#,
|
||||
"o",
|
||||
]),
|
||||
Some(vec![("NO_COLOR".to_owned(), "1".to_owned())]),
|
||||
false,
|
||||
);
|
||||
|
||||
assert!(out.contains("Oops custom inspect error"));
|
||||
assert!(err.is_empty());
|
||||
}
|
||||
|
|
|
@ -564,7 +564,13 @@ impl ReplSession {
|
|||
"Runtime.callFunctionOn",
|
||||
Some(json!({
|
||||
"executionContextId": self.context_id,
|
||||
"functionDeclaration": "function (object) { return Deno[Deno.internal].inspectArgs(['%o', object], { colors: !Deno.noColor }); }",
|
||||
"functionDeclaration": r#"function (object) {
|
||||
try {
|
||||
return Deno[Deno.internal].inspectArgs(["%o", object], { colors: !Deno.noColor });
|
||||
} catch (err) {
|
||||
return Deno[Deno.internal].inspectArgs(["%o", err]);
|
||||
}
|
||||
}"#,
|
||||
"arguments": [
|
||||
evaluate_result,
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue