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:
sigmaSd 2023-06-06 22:06:30 +01:00 committed by GitHub
parent 40d77c5605
commit 455b0eb8bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View file

@ -258,9 +258,15 @@ impl ReplSession {
Ok(if let Some(exception_details) = exception_details {
session.set_last_thrown_error(&result).await?;
let description = match exception_details.exception {
Some(exception) => exception
.description
.unwrap_or_else(|| "undefined".to_string()),
Some(exception) => {
if let Some(description) = exception.description {
description
} else if let Some(value) = exception.value {
value.to_string()
} else {
"undefined".to_string()
}
}
None => "Unknown exception".to_string(),
};
EvaluationOutput::Error(format!(