Приложение Electron падает при вызове autoUpdater.checkForUpdates - PullRequest
0 голосов
/ 19 сентября 2019

электрон: 6.0.9

электронное обновление: 4.1.2

Приложение Electron зависает при звонке autoUpdater.checkForUpdates без подключения к Интернету

Приложение аварийно завершает работу даже в окружении блока try catch

    try {
        autoUpdater.checkForUpdates();
    } catch(e) {
        logEverywhere('Error, Failed to check for updates!');
    }

Запустите этот тест на электронной скрипте (с autoUpdater.setFeedURL ("https://example.com/"))

Error: Error: net::ERR_NAME_NOT_RESOLVED

(node:10144) UnhandledPromiseRejectionWarning: Error: net::ERR_NAME_NOT_RESOLVED

(node:10144) UnhandledPromiseRejectionWarning: Error: net::ERR_NAME_NOT_RESOLVED

(node:10144) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:10144) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

(node:10144) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

(node:10144) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Electron exited with code 0.

1 Ответ

1 голос
/ 19 сентября 2019

autoUpdater.checkForUpdates() - это асинхронная функция, которая возвращает обещание.Вы не можете перехватить эти ошибки, используя try catch.

. Вот как вы ловите ошибки:

autoUpdater.checkForUpdates().catch(err => {
    console.error(`Something went wrong`, err);
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...