File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 270
270
error = null ;
271
271
}
272
272
} catch (e ) {
273
+ console .error (e ); // make it show up in the console, too, not just the UI
273
274
// @ts-ignore
274
275
show_error (e );
275
276
}
Original file line number Diff line number Diff line change 25
25
onversion? : (version : string ) => void ;
26
26
onchange? : () => void ;
27
27
download? : () => void ;
28
+ /**
29
+ * Invoked whenever there's a bundler or runtime error
30
+ */
31
+ onerror? : (error : Error ) => void ;
28
32
}
29
33
30
34
let {
40
44
previewTheme = ' light' ,
41
45
onversion,
42
46
onchange = () => {},
43
- download
47
+ download,
48
+ onerror
44
49
}: Props = $props ();
45
50
46
51
// TODO pass in real data
185
190
$toggleable = mobile && orientation === ' columns' && embedded !== ' output-only' ;
186
191
});
187
192
193
+ $effect (() => {
194
+ if (runtime_error ) {
195
+ onerror ?.(runtime_error );
196
+ }
197
+ });
198
+
199
+ $effect (() => {
200
+ if (bundler .result ?.error ) {
201
+ onerror ?.(bundler .result .error as Error );
202
+ }
203
+ });
204
+
188
205
let runes = $derived (
189
206
workspace .current .name .endsWith (' .svelte.js' ) ||
190
207
(workspace .current_compiled ?.result ?.metadata .runes ?? false )
235
252
{injectedCSS }
236
253
{previewTheme }
237
254
{workspace }
238
- runtimeError ={runtime_error }
255
+ bind: runtimeError ={runtime_error }
239
256
/>
240
257
</section >
241
258
{/ snippet }
Original file line number Diff line number Diff line change 1
1
import type { OutputChunk , RollupError } from '@rollup/browser' ;
2
+ import type { CompileError } from 'svelte/compiler' ;
2
3
3
4
export interface BundleResult {
4
5
uid : number ;
Original file line number Diff line number Diff line change 13
13
</script >
14
14
15
15
<main >
16
- <Repl bind:this ={repl } embedded =" output-only" />
16
+ <Repl
17
+ bind:this ={repl }
18
+ embedded =" output-only"
19
+ onerror ={(error ) => {
20
+ // @ts-expect-error so that v0 can react to REPL errors
21
+ window .__svelte_repl_onerror ?.(error );
22
+ }}
23
+ />
17
24
</main >
18
25
19
26
<style >
You can’t perform that action at this time.
0 commit comments