client: Display critical error toast instead of blank screen

This commit is contained in:
Elian Doran 2024-07-27 12:05:24 +03:00
parent 7bb70bb659
commit 22761d8a00
No known key found for this signature in database

View File

@ -2,6 +2,7 @@ import appContext from "./components/app_context.js";
import utils from './services/utils.js'; import utils from './services/utils.js';
import noteTooltipService from './services/note_tooltip.js'; import noteTooltipService from './services/note_tooltip.js';
import bundleService from "./services/bundle.js"; import bundleService from "./services/bundle.js";
import toastService from "./services/toast.js";
import noteAutocompleteService from './services/note_autocomplete.js'; import noteAutocompleteService from './services/note_autocomplete.js';
import macInit from './services/mac_init.js'; import macInit from './services/mac_init.js';
import electronContextMenu from "./menus/electron_context_menu.js"; import electronContextMenu from "./menus/electron_context_menu.js";
@ -9,8 +10,16 @@ import DesktopLayout from "./layouts/desktop_layout.js";
import glob from "./services/glob.js"; import glob from "./services/glob.js";
bundleService.getWidgetBundlesByParent().then(widgetBundles => { bundleService.getWidgetBundlesByParent().then(widgetBundles => {
appContext.setLayout(new DesktopLayout(widgetBundles)); appContext.setLayout(new DesktopLayout(widgetBundles));
appContext.start(); appContext.start()
.catch((e) => {
toastService.showPersistent({
title: "Critical error",
icon: "alert",
message: `A critical error has occurred which prevents the client application from starting:\n\n${e.message}\n\nThis is most likely caused by a script failing in an unexpected way. Try starting the application in safe mode and addressing the issue.`,
});
console.error("Critical error occured", e);
});
}); });
glob.setupGlobs(); glob.setupGlobs();