summaryrefslogtreecommitdiff
path: root/cli/tools/repl/session.rs
diff options
context:
space:
mode:
authorsigmaSd <bedisnbiba@gmail.com>2023-06-06 22:06:30 +0100
committerGitHub <noreply@github.com>2023-06-06 23:06:30 +0200
commit455b0eb8bb8445f80d9c80a9161f18c1dede5733 (patch)
treead5560afa85814d8ad7b40e0b85736f50d5aef53 /cli/tools/repl/session.rs
parent40d77c56055cca89437b36bb5763a820ef931539 (diff)
fix(repl): correctly print string exception (#19391)
Fixes a recent regression where `throw "hello"` in the repl prints `Uncaught undefined` instead of `throw "hello"`
Diffstat (limited to 'cli/tools/repl/session.rs')
-rw-r--r--cli/tools/repl/session.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs
index 40cf7d3b0..4a30c93c4 100644
--- a/cli/tools/repl/session.rs
+++ b/cli/tools/repl/session.rs
@@ -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!(