diff --git a/frontend/config.json b/frontend/config.json index 87e1488..b793d51 100644 --- a/frontend/config.json +++ b/frontend/config.json @@ -3,6 +3,7 @@ "files": "ts/files.ts", "layout": "sass/layout.scss", "index": "sass/index.scss", + "error": "sass/error.scss", "service-settings": "sass/service-settings.scss" } } \ No newline at end of file diff --git a/frontend/error.html b/frontend/error.html new file mode 100644 index 0000000..39173a3 --- /dev/null +++ b/frontend/error.html @@ -0,0 +1,22 @@ + + + + + An error occured + + + + + + + + + +

Oops

+

An error has occurred while loading this document.

+

Please check your internet connection and this service's URL.

+

If you can load the actual URL in your favorite web browser, please file us a bug report.

+ + diff --git a/frontend/sass/error.scss b/frontend/sass/error.scss new file mode 100644 index 0000000..3529fc9 --- /dev/null +++ b/frontend/sass/error.scss @@ -0,0 +1,9 @@ +html, body { + height: 100%; +} +body { + display: flex; + flex-direction: column; + justify-content: center; + align-self: center; +} \ No newline at end of file diff --git a/frontend/ts/index.ts b/frontend/ts/index.ts index 61cee8d..d0c84d3 100644 --- a/frontend/ts/index.ts +++ b/frontend/ts/index.ts @@ -26,7 +26,7 @@ let securityButton: HTMLElement | null, backButton: HTMLElement | null, refreshButton: HTMLElement | null; let addButton, settingsButton; -let emptyPage: string; +let emptyPage: string, errorPage: string; let urlPreview: HTMLElement | null; let serviceSelector: HTMLElement | null; @@ -128,7 +128,7 @@ function openServiceContextMenu(event: Event, serviceId: number) { } -ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUrl, config) => { +ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUrl, errorUrl, config) => { // App info appInfo.title = appData.title; @@ -179,6 +179,7 @@ ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUr // Empty emptyPage = emptyUrl; + errorPage = errorUrl; // Url preview element urlPreview = document.getElementById("url-preview"); @@ -477,6 +478,11 @@ function loadService(serviceId: number, service: any) { // eventual future human mistakes. service.view.setAttribute('webpreferences', 'contextIsolation=yes'); + // Error handling + service.view.addEventListener('did-fail-load', (e: Event) => { + service.view.setAttribute('src', errorPage); + }); + // Append element to DOM document.querySelector('#services')?.appendChild(service.view); diff --git a/src/windows/MainWindow.ts b/src/windows/MainWindow.ts index 7e91f82..776a072 100644 --- a/src/windows/MainWindow.ts +++ b/src/windows/MainWindow.ts @@ -147,6 +147,7 @@ export default class MainWindow extends Window { Meta.ICON_SETS, this.activeService, path.resolve(Meta.RESOURCES_PATH, 'empty.html'), + path.resolve(Meta.RESOURCES_PATH, 'error.html'), this.config ); }