mirror of https://github.com/sveltejs/svelte
parent
7d72187fed
commit
34c2900a64
@ -1,7 +1,14 @@
|
||||
<script>
|
||||
const { things } = $props();
|
||||
const { count } = $props();
|
||||
|
||||
const d = $derived.by(() => {
|
||||
if (count === 1) {
|
||||
throw new Error('kaboom')
|
||||
}
|
||||
return count
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
things
|
||||
})
|
||||
d;
|
||||
});
|
||||
</script>
|
||||
|
@ -1,16 +1,18 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
|
||||
let test = $derived.by(() => {
|
||||
function maybe_throw() {
|
||||
if (count > 1) {
|
||||
throw new Error('test');
|
||||
}
|
||||
});
|
||||
|
||||
return count;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:boundary onerror={(e) => { throw(e) }}>
|
||||
<div>Count: {count}</div>
|
||||
<button onclick={() => count++}>Increment</button>
|
||||
{count} / {test}
|
||||
{count} / {maybe_throw()}
|
||||
</svelte:boundary>
|
||||
|
||||
|
Loading…
Reference in new issue