gpt4 book ai didi

electron - 调用autoUpdater.checkForUpdates时Electron应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 12:24:13 25 4
gpt4 key购买 nike

electron : 6.0.9

electron-updater: 4.1.2



调用 autoUpdater.checkForUpdates时 Electron 应用程序崩溃
没有互联网连接

应用程序甚至在 try catch 块中被包围也崩溃了
    try {
autoUpdater.checkForUpdates();
} catch(e) {
logEverywhere('Error, Failed to check for updates!');
}

Run this test on electron fiddle (with 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.

最佳答案

autoUpdater.checkForUpdates()是一个返回 promise 的异步函数。您无法使用try catch捕获这些错误。

这是您捕获错误的方式:

autoUpdater.checkForUpdates().catch(err => {
console.error(`Something went wrong`, err);
});

关于electron - 调用autoUpdater.checkForUpdates时Electron应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58008137/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com