2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 19:09:01 +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[]) { export function rendererLog(main: Main, ...args: unknown[]) {
main.mainWindow?.webContents.send(IPC_CHANNELS.CONSOLE_LOG, ...args); 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 { app, dialog } from 'electron';
import { autoUpdater, UpdateInfo } from 'electron-updater'; import { autoUpdater, UpdateInfo } from 'electron-updater';
import { Main } from '../main'; import { Main } from '../main';
import { isNetworkError } from './helpers';
export default function registerAutoUpdaterListeners(main: Main) { export default function registerAutoUpdaterListeners(main: Main) {
autoUpdater.autoDownload = false; autoUpdater.autoDownload = false;
autoUpdater.allowPrerelease = true;
autoUpdater.autoInstallOnAppQuit = true; autoUpdater.autoInstallOnAppQuit = true;
autoUpdater.on('error', (error) => { autoUpdater.on('error', (error) => {
if (!main.checkedForUpdate) { if (!main.checkedForUpdate) {
main.checkedForUpdate = true; main.checkedForUpdate = true;
}
if (isNetworkError(error)) {
return; return;
} }

View File

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