File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
packages/svelte/tests/runtime-runes/samples/error-boundary-23 Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ import { flushSync } from 'svelte' ;
2+ import { test } from '../../test' ;
3+
4+ export default test ( {
5+ test ( { assert, target, logs } ) {
6+ let btn = target . querySelector ( 'button' ) ;
7+
8+ btn ?. click ( ) ;
9+ btn ?. click ( ) ;
10+ flushSync ( ) ;
11+
12+ assert . deepEqual ( logs , [ 'error caught 1' , 'error caught 2' ] ) ;
13+ }
14+ } ) ;
Original file line number Diff line number Diff line change 1+ <script lang =" ts" >
2+ import Test from ' ./test.svelte' ;
3+ </script >
4+
5+ <svelte:boundary onerror ={(e ) => {console .log (e .stack )}}>
6+ <Test />
7+ </svelte:boundary >
Original file line number Diff line number Diff line change 1+ <script >
2+ let count = $state (0 );
3+
4+ let test = $derived .by (() => {
5+ if (count > 1 ) {
6+ throw new Error (' test' );
7+ }
8+ });
9+ </script >
10+
11+ <svelte:boundary onerror ={(e ) => {console .log (' error caught 1' )}}>
12+ <div >Count: {count }</div >
13+ <button onclick ={() => count ++ }>Increment</button >
14+ {count } / {test }
15+ </svelte:boundary >
16+
17+
18+ <svelte:boundary onerror ={(e ) => {console .log (' error caught 2' )}}>
19+ <div >Count: {count }</div >
20+ <button onclick ={() => count ++ }>Increment</button >
21+ {count } / {test }
22+ </svelte:boundary >
You can’t perform that action at this time.
0 commit comments