Add "file not found" error and do not catch user aborts as load errors
This commit is contained in:
parent
12f5d32322
commit
0c6d6a466b
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>Oops</h1>
|
<h1>Oops</h1>
|
||||||
<p>An error has occurred while loading this document.</p>
|
<p>A connection error has occurred.</p>
|
||||||
<p>Please check your internet connection and this service's URL.</p>
|
<p>Please check your internet connection and this service's URL.</p>
|
||||||
<p>If you can load the actual URL in your favorite web browser, please file us a bug report.</p>
|
<p>If you can load the actual URL in your favorite web browser, please file us a bug report.</p>
|
||||||
</body>
|
</body>
|
20
frontend/file_not_found_error.html
Normal file
20
frontend/file_not_found_error.html
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>An error occured</title>
|
||||||
|
<meta http-equiv="Content-Security-Policy"
|
||||||
|
content="style-src 'self' 'unsafe-inline' https://use.fontawesome.com; font-src 'self' https://use.fontawesome.com; script-src 'self'">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css"
|
||||||
|
integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="css/layout.css">
|
||||||
|
<link rel="stylesheet" href="css/error.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Oops</h1>
|
||||||
|
<p>File not found.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
clipboard,
|
clipboard,
|
||||||
|
DidFailLoadEvent,
|
||||||
ipcRenderer,
|
ipcRenderer,
|
||||||
PageFaviconUpdatedEvent,
|
PageFaviconUpdatedEvent,
|
||||||
remote,
|
remote,
|
||||||
@ -26,7 +27,7 @@ let securityButton: HTMLElement | null,
|
|||||||
backButton: HTMLElement | null,
|
backButton: HTMLElement | null,
|
||||||
refreshButton: HTMLElement | null;
|
refreshButton: HTMLElement | null;
|
||||||
let addButton, settingsButton;
|
let addButton, settingsButton;
|
||||||
let emptyPage: string, errorPage: string;
|
let pages: any;
|
||||||
let urlPreview: HTMLElement | null;
|
let urlPreview: HTMLElement | null;
|
||||||
let serviceSelector: HTMLElement | null;
|
let serviceSelector: HTMLElement | null;
|
||||||
|
|
||||||
@ -128,7 +129,7 @@ function openServiceContextMenu(event: Event, serviceId: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUrl, errorUrl, config) => {
|
ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, urls, config) => {
|
||||||
// App info
|
// App info
|
||||||
appInfo.title = appData.title;
|
appInfo.title = appData.title;
|
||||||
|
|
||||||
@ -178,8 +179,7 @@ ipcRenderer.on('data', (event, appData, iconSets, actualSelectedService, emptyUr
|
|||||||
setActiveService(actualSelectedService);
|
setActiveService(actualSelectedService);
|
||||||
|
|
||||||
// Empty
|
// Empty
|
||||||
emptyPage = emptyUrl;
|
pages = urls;
|
||||||
errorPage = errorUrl;
|
|
||||||
|
|
||||||
// Url preview element
|
// Url preview element
|
||||||
urlPreview = document.getElementById("url-preview");
|
urlPreview = document.getElementById("url-preview");
|
||||||
@ -475,15 +475,21 @@ function loadService(serviceId: number, service: any) {
|
|||||||
service.view.setAttribute('enableRemoteModule', 'false');
|
service.view.setAttribute('enableRemoteModule', 'false');
|
||||||
service.view.setAttribute('partition', 'persist:service_' + service.partition);
|
service.view.setAttribute('partition', 'persist:service_' + service.partition);
|
||||||
service.view.setAttribute('autosize', 'true');
|
service.view.setAttribute('autosize', 'true');
|
||||||
service.view.setAttribute('src', emptyPage);
|
service.view.setAttribute('src', pages?.empty);
|
||||||
|
|
||||||
// Enable context isolation. This is currently not used as there is no preload script; however it could prevent
|
// Enable context isolation. This is currently not used as there is no preload script; however it could prevent
|
||||||
// eventual future human mistakes.
|
// eventual future human mistakes.
|
||||||
service.view.setAttribute('webpreferences', 'contextIsolation=yes');
|
service.view.setAttribute('webpreferences', 'contextIsolation=yes');
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
service.view.addEventListener('did-fail-load', (e: Event) => {
|
service.view.addEventListener('did-fail-load', (e: DidFailLoadEvent) => {
|
||||||
service.view.setAttribute('src', errorPage);
|
if (e.errorCode <= -100 && e.errorCode > -200) {
|
||||||
|
service.view.setAttribute('src', pages?.connectionError);
|
||||||
|
} else if (e.errorCode === -6) {
|
||||||
|
service.view.setAttribute('src', pages?.fileNotFound);
|
||||||
|
} else if (e.errorCode !== -3) {
|
||||||
|
console.error('Unhandled error:', e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Append element to DOM
|
// Append element to DOM
|
||||||
|
@ -146,8 +146,11 @@ export default class MainWindow extends Window {
|
|||||||
Meta.title,
|
Meta.title,
|
||||||
Meta.ICON_SETS,
|
Meta.ICON_SETS,
|
||||||
this.activeService,
|
this.activeService,
|
||||||
path.resolve(Meta.RESOURCES_PATH, 'empty.html'),
|
{
|
||||||
path.resolve(Meta.RESOURCES_PATH, 'error.html'),
|
empty: path.resolve(Meta.RESOURCES_PATH, 'empty.html'),
|
||||||
|
connectionError: path.resolve(Meta.RESOURCES_PATH, 'connection_error.html'),
|
||||||
|
fileNotFound: path.resolve(Meta.RESOURCES_PATH, 'file_not_found_error.html'),
|
||||||
|
},
|
||||||
this.config
|
this.config
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user