Skip to content

Commit 0572d62

Browse files
committed
extract app load error handler from app.js
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 343d4ea commit 0572d62

2 files changed

Lines changed: 21 additions & 28 deletions

File tree

‎src/vector/app.js‎

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -151,33 +151,21 @@ export async function loadApp(fragParams: {}) {
151151

152152
platform.startUpdater();
153153

154-
try {
155-
// Don't bother loading the app until the config is verified
156-
const config = await verifyServerConfig();
157-
const MatrixChat = sdk.getComponent('structures.MatrixChat');
158-
return <MatrixChat
159-
onNewScreen={onNewScreen}
160-
makeRegistrationUrl={makeRegistrationUrl}
161-
ConferenceHandler={VectorConferenceHandler}
162-
config={config}
163-
realQueryParams={params}
164-
startingFragmentQueryParams={fragParams}
165-
enableGuest={!config.disable_guests}
166-
onTokenLoginCompleted={onTokenLoginCompleted}
167-
initialScreenAfterLogin={getScreenFromLocation(window.location)}
168-
defaultDeviceDisplayName={platform.getDefaultDeviceDisplayName()}
169-
/>;
170-
} catch (err) {
171-
console.error(err);
172-
173-
let errorMessage = err.translatedMessage
174-
|| _t("Unexpected error preparing the app. See console for details.");
175-
errorMessage = <span>{errorMessage}</span>;
176-
177-
// Like the compatibility page, AWOOOOOGA at the user
178-
const GenericErrorPage = sdk.getComponent("structures.GenericErrorPage");
179-
return <GenericErrorPage message={errorMessage} title={_t("Your Riot is misconfigured")} />;
180-
}
154+
// Don't bother loading the app until the config is verified
155+
const config = await verifyServerConfig();
156+
const MatrixChat = sdk.getComponent('structures.MatrixChat');
157+
return <MatrixChat
158+
onNewScreen={onNewScreen}
159+
makeRegistrationUrl={makeRegistrationUrl}
160+
ConferenceHandler={VectorConferenceHandler}
161+
config={config}
162+
realQueryParams={params}
163+
startingFragmentQueryParams={fragParams}
164+
enableGuest={!config.disable_guests}
165+
onTokenLoginCompleted={onTokenLoginCompleted}
166+
initialScreenAfterLogin={getScreenFromLocation(window.location)}
167+
defaultDeviceDisplayName={platform.getDefaultDeviceDisplayName()}
168+
/>;
181169
}
182170

183171
async function verifyServerConfig() {

‎src/vector/index.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ limitations under the License.
2121
// Require common CSS here; this will make webpack process it into bundle.css.
2222
// Our own CSS (which is themed) is imported via separate webpack entry points
2323
// in webpack.config.js
24+
import React from "react";
25+
2426
require('gfm.css/gfm.css');
2527
require('highlight.js/styles/github.css');
2628

@@ -192,7 +194,10 @@ async function start() {
192194
await loadApp(fragparts.params);
193195
} catch (err) {
194196
console.error(err);
195-
await showError(err);
197+
// Like the compatibility page, AWOOOOOGA at the user
198+
await showError(_t("Your Riot is misconfigured"), [
199+
err.translatedMessage || _t("Unexpected error preparing the app. See console for details."),
200+
]);
196201
}
197202
}
198203
start().catch(err => {

0 commit comments

Comments
 (0)