mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -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());
|
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",
|
"Runtime.callFunctionOn",
|
||||||
Some(json!({
|
Some(json!({
|
||||||
"executionContextId": self.context_id,
|
"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": [
|
"arguments": [
|
||||||
evaluate_result,
|
evaluate_result,
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Reference in a new issue