mirror of https://github.com/sveltejs/svelte
fix: rethrow errors from await block if no catch block exists (#13819)
* chore: highlight swallowed errors from await blocks in DEV * chore: highlight swallowed errors from await blocks in DEV * chore: highlight swallowed errors from await blocks in DEV * lint * feedback * feedback * add test * Update packages/svelte/tests/runtime-runes/samples/await-no-catch-error/main.svelte --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>revert-13651-compile-warning
parent
81f9bdd376
commit
7bbaedd6c7
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: rethrow errors from await block if no catch block exists
|
@ -0,0 +1,22 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
const b1 = target.querySelector('button');
|
||||
|
||||
let err = '';
|
||||
window.addEventListener('error', (e) => {
|
||||
e.preventDefault();
|
||||
err = e.message;
|
||||
});
|
||||
|
||||
b1?.click();
|
||||
await Promise.resolve();
|
||||
flushSync();
|
||||
|
||||
assert.throws(() => {
|
||||
throw err;
|
||||
}, /Test/);
|
||||
}
|
||||
});
|
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
const promise = Promise.reject('Test');
|
||||
let toggle = $state(false);
|
||||
</script>
|
||||
|
||||
<button onclick={() => toggle = !toggle}>toggle</button>
|
||||
|
||||
{#if toggle}
|
||||
{#await promise}{/await}
|
||||
{/if}
|
Loading…
Reference in new issue