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 270270 error = null ;
271271 }
272272 } catch (e ) {
273+ console .error (e ); // make it show up in the console, too, not just the UI
273274 // @ts-ignore
274275 show_error (e );
275276 }
Original file line number Diff line number Diff line change 2525 onversion? : (version : string ) => void ;
2626 onchange? : () => void ;
2727 download? : () => void ;
28+ /**
29+ * Invoked whenever there's a bundler or runtime error
30+ */
31+ onerror? : (error : Error ) => void ;
2832 }
2933
3034 let {
4044 previewTheme = ' light' ,
4145 onversion,
4246 onchange = () => {},
43- download
47+ download,
48+ onerror
4449 }: Props = $props ();
4550
4651 // TODO pass in real data
185190 $toggleable = mobile && orientation === ' columns' && embedded !== ' output-only' ;
186191 });
187192
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+
188205 let runes = $derived (
189206 workspace .current .name .endsWith (' .svelte.js' ) ||
190207 (workspace .current_compiled ?.result ?.metadata .runes ?? false )
235252 {injectedCSS }
236253 {previewTheme }
237254 {workspace }
238- runtimeError ={runtime_error }
255+ bind: runtimeError ={runtime_error }
239256 />
240257 </section >
241258 {/ snippet }
Original file line number Diff line number Diff line change 11import type { OutputChunk , RollupError } from '@rollup/browser' ;
2+ import type { CompileError } from 'svelte/compiler' ;
23
34export interface BundleResult {
45 uid : number ;
Original file line number Diff line number Diff line change 1313 </script >
1414
1515<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+ />
1724</main >
1825
1926<style >
You can’t perform that action at this time.
0 commit comments