mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
fix: handle errors thrown in await catch attrs
This commit is contained in:
parent
59dd026483
commit
4286236b0e
5
.changeset/gold-timers-sleep.md
Normal file
5
.changeset/gold-timers-sleep.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"marko": patch
|
||||
---
|
||||
|
||||
Handle errors thrown in await catch attribute
|
||||
@ -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);
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
---
|
||||
BEFORE
|
||||
<await(Promise.reject(new Error("Something went wrong!")))>
|
||||
<@then|testData|>Success!</@then>
|
||||
<@catch|err|>
|
||||
$ throw err
|
||||
</@catch>
|
||||
</await>
|
||||
AFTER
|
||||
---
|
||||
@ -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");
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user