mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 00:29:09 -05:00
fix(cli/repl): await Promise.any([])... (#15623)
This commit is contained in:
parent
bacfd5284f
commit
eafec30b7a
4 changed files with 40 additions and 7 deletions
|
@ -861,3 +861,17 @@ fn repl_report_error() {
|
||||||
assert_contains!(out, "1\n2\nundefined\n");
|
assert_contains!(out, "1\n2\nundefined\n");
|
||||||
assert!(err.is_empty());
|
assert!(err.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pty_aggregate_error() {
|
||||||
|
let (out, err) = util::run_and_collect_output(
|
||||||
|
true,
|
||||||
|
"repl",
|
||||||
|
Some(vec!["await Promise.any([])"]),
|
||||||
|
Some(vec![("NO_COLOR".to_owned(), "1".to_owned())]),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_contains!(out, "AggregateError");
|
||||||
|
assert!(err.is_empty());
|
||||||
|
}
|
||||||
|
|
|
@ -2027,3 +2027,14 @@ Deno.test(function inspectStringAbbreviation() {
|
||||||
'[ "This is a ..." ]',
|
'[ "This is a ..." ]',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deno.test(async function inspectAggregateError() {
|
||||||
|
try {
|
||||||
|
await Promise.any([]);
|
||||||
|
} catch (err) {
|
||||||
|
assertEquals(
|
||||||
|
Deno.inspect(err).trimEnd(),
|
||||||
|
"AggregateError: All promises were rejected",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -165,8 +165,18 @@ impl ReplSession {
|
||||||
exception_details,
|
exception_details,
|
||||||
} = evaluate_response.value;
|
} = evaluate_response.value;
|
||||||
|
|
||||||
if exception_details.is_some() {
|
Ok(if let Some(exception_details) = exception_details {
|
||||||
self.set_last_thrown_error(&result).await?;
|
self.set_last_thrown_error(&result).await?;
|
||||||
|
let description = match exception_details.exception {
|
||||||
|
Some(exception) => exception
|
||||||
|
.description
|
||||||
|
.unwrap_or_else(|| "Unknown exception".to_string()),
|
||||||
|
None => "Unknown exception".to_string(),
|
||||||
|
};
|
||||||
|
EvaluationOutput::Error(format!(
|
||||||
|
"{} {}",
|
||||||
|
exception_details.text, description
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
self
|
self
|
||||||
.language_server
|
.language_server
|
||||||
|
@ -174,12 +184,8 @@ impl ReplSession {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
self.set_last_eval_result(&result).await?;
|
self.set_last_eval_result(&result).await?;
|
||||||
}
|
let value = self.get_eval_value(&result).await?;
|
||||||
|
EvaluationOutput::Value(value)
|
||||||
let value = self.get_eval_value(&result).await?;
|
|
||||||
Ok(match exception_details {
|
|
||||||
Some(_) => EvaluationOutput::Error(format!("Uncaught {}", value)),
|
|
||||||
None => EvaluationOutput::Value(value),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
|
@ -959,6 +959,8 @@
|
||||||
if (RegExpPrototypeTest(/\s+at/, line)) {
|
if (RegExpPrototypeTest(/\s+at/, line)) {
|
||||||
ArrayPrototypeUnshift(stackLines, line);
|
ArrayPrototypeUnshift(stackLines, line);
|
||||||
break;
|
break;
|
||||||
|
} else if (typeof line === "undefined") {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
finalMessage += line;
|
finalMessage += line;
|
||||||
|
|
Loading…
Reference in a new issue