fix: handle errors thrown in await catch attrs

This commit is contained in:
Ryan Turnquist 2023-07-26 10:19:59 -07:00 committed by Dylan Piercey
parent 59dd026483
commit 4286236b0e
4 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,5 @@
---
"marko": patch
---
Handle errors thrown in await catch attribute

View File

@ -220,7 +220,11 @@ function renderContents(err, data, input, out) {
if (err) {
if (input.catch) {
if (errorRenderer) {
errorRenderer(out, err);
try {
errorRenderer(out, err);
} catch (err2) {
out.error(err2);
}
}
} else {
out.error(err);

View File

@ -0,0 +1,10 @@
---
BEFORE
<await(Promise.reject(new Error("Something went wrong!")))>
<@then|testData|>Success!</@then>
<@catch|err|>
$ throw err
</@catch>
</await>
AFTER
---

View File

@ -0,0 +1,10 @@
var expect = require("chai").expect;
exports.templateData = {};
exports.skip_vdom = "VDOM does not support async components";
exports.checkError = function (e) {
var message = e.toString();
expect(message).to.contain("Something went wrong");
};