@@ -97,6 +97,8 @@ async function start() {
9797 loadLanguage,
9898 loadTheme,
9999 loadApp,
100+ showError,
101+ _t,
100102 } = await import (
101103 /* webpackChunkName: "init" */
102104 /* webpackPreload: true */
@@ -130,12 +132,18 @@ async function start() {
130132 // load config requires the platform to be ready
131133 const loadConfigPromise = loadConfig ( ) ;
132134
133- let configError ;
134135 try {
135136 // await config here
136137 await loadConfigPromise ;
137- } catch ( err ) {
138- configError = err ;
138+ } catch ( error ) {
139+ // Now that we've loaded the theme (CSS), display the config syntax error if needed.
140+ if ( error . err && error . err instanceof SyntaxError ) {
141+ return showError ( _t ( "Your Riot is misconfigured" ) , [
142+ _t ( "Your Riot configuration contains invalid JSON. Please correct the problem and reload the page." ) ,
143+ _t ( "The message from the parser is: %(message)s" , { message : error . err . message || _t ( "Invalid JSON" ) } ) ,
144+ ] ) ;
145+ }
146+ return showError ( _t ( "Unable to load config file: please refresh the page to try again." ) ) ;
139147 }
140148
141149 // Load language after loading config.json so that settingsDefaults.language can be applied
@@ -150,9 +158,27 @@ async function start() {
150158 await loadThemePromise ;
151159 await loadLanguagePromise ;
152160
153- // Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
154- // run on the components.
155- await loadApp ( fragparts . params , acceptBrowser , configError ) ;
161+ if ( ! acceptBrowser ) {
162+ await new Promise ( resolve => {
163+ // todo
164+ } ) ;
165+ }
166+
167+ // Finally, load the app. All of the other react-sdk imports are in this file which causes the skinner to
168+ // run on the components.
169+ await loadApp ( fragparts . params , acceptBrowser ) ;
170+ } catch ( err ) {
171+ console . trace ( err ) ;
172+ // check errors in this order:
173+ // Browser Compatibility (skippable)
174+ // config.json
175+ // runtime errors
176+ const { showError } = await import (
177+ /* webpackChunkName: "init" */
178+ /* webpackPreload: true */
179+ "./init" ) ;
180+ await showError ( err ) ;
181+ }
156182}
157183start ( ) . catch ( err => {
158184 if ( ! acceptBrowser ) {
0 commit comments