From a9b21ea64523fde9aee9d859b233ba54e800324a Mon Sep 17 00:00:00 2001 From: jamesread Date: Mon, 1 Dec 2025 00:22:18 +0000 Subject: [PATCH] feat: Display a big error message if OliveTin initialization fails --- frontend/main.js | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index 4227b53..699743b 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -11,7 +11,7 @@ import { createConnectTransport } from '@connectrpc/connect-web' import { OliveTinApiService } from './resources/scripts/gen/olivetin/api/v1/olivetin_pb' -import { createApp } from 'vue' +import { createApp, h } from 'vue' import { createI18n } from 'vue-i18n' import router from './resources/vue/router.js' @@ -91,12 +91,33 @@ function setupVue (i18nSettings) { app.mount('#app') } +function setupErrorDisplay (errorMessage) { + const ErrorApp = { + render() { + return h('section', { class: 'bad', style: 'padding: 2em; text-align: center; margin: 2em auto;' }, [ + h('h2', 'OliveTin Init Failed'), + h('p', errorMessage), + h('p', 'Please check your browser console for more details.') + ]) + } + } + + const app = createApp(ErrorApp) + app.mount('#app') +} + async function main () { - const i18nSettings = await initClient() + try { + const i18nSettings = await initClient() - initWebsocket() + initWebsocket() - setupVue(i18nSettings) + setupVue(i18nSettings) + } catch (err) { + const errorMessage = err.message || 'Failed to initialize. Please check your configuration and try again.' + console.error('Init failed:', err) + setupErrorDisplay(errorMessage) + } } main()