mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(repl): correctly print string exception (#19391)
Fixes a recent regression where `throw "hello"` in the repl prints `Uncaught undefined` instead of `throw "hello"`
This commit is contained in:
parent
7059acc662
commit
9a6d319e18
2 changed files with 13 additions and 3 deletions
|
@ -814,6 +814,10 @@ fn repl_reject() {
|
||||||
console.expect(" at <anonymous>");
|
console.expect(" at <anonymous>");
|
||||||
console.write_line("console.log(2);");
|
console.write_line("console.log(2);");
|
||||||
console.expect("2");
|
console.expect("2");
|
||||||
|
console.write_line(r#"throw "hello";"#);
|
||||||
|
console.expect(r#"Uncaught "hello""#);
|
||||||
|
console.write_line(r#"throw `hello ${"world"}`;"#);
|
||||||
|
console.expect(r#"Uncaught "hello world""#);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,9 +258,15 @@ impl ReplSession {
|
||||||
Ok(if let Some(exception_details) = exception_details {
|
Ok(if let Some(exception_details) = exception_details {
|
||||||
session.set_last_thrown_error(&result).await?;
|
session.set_last_thrown_error(&result).await?;
|
||||||
let description = match exception_details.exception {
|
let description = match exception_details.exception {
|
||||||
Some(exception) => exception
|
Some(exception) => {
|
||||||
.description
|
if let Some(description) = exception.description {
|
||||||
.unwrap_or_else(|| "undefined".to_string()),
|
description
|
||||||
|
} else if let Some(value) = exception.value {
|
||||||
|
value.to_string()
|
||||||
|
} else {
|
||||||
|
"undefined".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
None => "Unknown exception".to_string(),
|
None => "Unknown exception".to_string(),
|
||||||
};
|
};
|
||||||
EvaluationOutput::Error(format!(
|
EvaluationOutput::Error(format!(
|
||||||
|
|
Loading…
Reference in a new issue