2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00

fix: dont report network errors on updation

This commit is contained in:
18alantom 2022-08-31 14:50:54 +05:30
parent cd234f8826
commit ef26c18d50
3 changed files with 25 additions and 1 deletions

View File

@ -73,3 +73,17 @@ export async function getErrorHandledReponse(func: () => Promise<unknown>) {
export function rendererLog(main: Main, ...args: unknown[]) {
main.mainWindow?.webContents.send(IPC_CHANNELS.CONSOLE_LOG, ...args);
}
export function isNetworkError(error: Error) {
switch (error?.message) {
case 'net::ERR_INTERNET_DISCONNECTED':
case 'net::ERR_PROXY_CONNECTION_FAILED':
case 'net::ERR_CONNECTION_RESET':
case 'net::ERR_CONNECTION_CLOSE':
case 'net::ERR_NAME_NOT_RESOLVED':
case 'net::ERR_CONNECTION_TIMED_OUT':
return true;
default:
return false;
}
}

View File

@ -2,14 +2,19 @@ import { emitMainProcessError } from 'backend/helpers';
import { app, dialog } from 'electron';
import { autoUpdater, UpdateInfo } from 'electron-updater';
import { Main } from '../main';
import { isNetworkError } from './helpers';
export default function registerAutoUpdaterListeners(main: Main) {
autoUpdater.autoDownload = false;
autoUpdater.allowPrerelease = true;
autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.on('error', (error) => {
if (!main.checkedForUpdate) {
main.checkedForUpdate = true;
}
if (isNetworkError(error)) {
return;
}

View File

@ -12,7 +12,8 @@ import { getLanguageMap } from './getLanguageMap';
import {
getConfigFilesWithModified,
getErrorHandledReponse,
setAndGetCleanedConfigFiles,
isNetworkError,
setAndGetCleanedConfigFiles
} from './helpers';
import { saveHtmlAsPdf } from './saveHtmlAsPdf';
@ -60,6 +61,10 @@ export default function registerIpcMainActionListeners(main: Main) {
try {
await autoUpdater.checkForUpdates();
} catch (error) {
if (isNetworkError(error as Error)) {
return;
}
emitMainProcessError(error);
}
main.checkedForUpdate = true;