Move hideErrorTypes & showError() to PythonBridge

This commit is contained in:
miruka 2020-08-03 01:19:08 -04:00
parent 040e966d27
commit c813e92ac7
9 changed files with 24 additions and 25 deletions

View File

@ -57,7 +57,7 @@ HFileDialogOpener {
)
)
if (unknown) utils.showError(type, traceback, uuid)
if (unknown) py.showError(type, traceback, uuid)
})
}

View File

@ -61,7 +61,7 @@ HBox {
type.startsWith("Matrix") ?
text = qsTr("Error contacting server: %1").arg(type) :
utils.showError(type, traceback, uuid)
py.showError(type, traceback, uuid)
errorMessage.text = text
})

View File

@ -33,7 +33,7 @@ SignInBase {
type === "MatrixUserDeactivated" ?
txt = qsTr("This account was deactivated") :
utils.showError(type, traceback, uuid)
py.showError(type, traceback, uuid)
page.errorMessage.text = txt
},

View File

@ -5,6 +5,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import "../Base"
import "../Base/Buttons"
import "../PythonBridge" as PythonBridge
HColumnPopup {
id: popup
@ -54,8 +55,8 @@ HColumnPopup {
text: qsTr("Hide this type of error until restart")
onCheckedChanged:
checked ?
window.hideErrorTypes.add(errorType) :
window.hideErrorTypes.delete(errorType)
PythonBridge.Globals.hideErrorTypes.add(errorType) :
PythonBridge.Globals.hideErrorTypes.delete(errorType)
Layout.fillWidth: true
}

View File

@ -1,8 +1,8 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import ".."
import "../.."
import ".."
QtObject {
signal deviceUpdateSignal(string forAccount)
@ -37,7 +37,7 @@ QtObject {
onError ?
onError(type, args, error, traceback, uuid) :
utils.showError(type, traceback, "", uuid)
py.showError(type, traceback, "", uuid)
return
}
@ -48,7 +48,7 @@ QtObject {
function onLoopException(message, error, traceback) {
// No need to log these here, the asyncio exception handler does it
const type = py.getattr(py.getattr(error, "__class__"), "__name__")
utils.showError(type, traceback, message)
py.showError(type, traceback, message)
}
function onModelItemSet(syncId, indexThen, indexNow, changedFields){

View File

@ -5,4 +5,5 @@ import QtQuick 2.12
QtObject {
readonly property var pendingCoroutines: ({})
readonly property var hideErrorTypes: new Set(["gaierror", "SSLError"])
}

View File

@ -71,4 +71,18 @@ Python {
if (callback) { callback(settings, uiState, theme) }
})
}
function showError(type, traceback, sourceIndication="", message="") {
console.error(`python: ${sourceIndication}\n${traceback}`)
if (Globals.hideErrorTypes.has(type)) {
console.info("Not showing popup for ignored error type " + type)
return
}
utils.makePopup(
"Popups/UnexpectedErrorPopup.qml",
{ errorType: type, message, traceback },
)
}
}

View File

@ -75,21 +75,6 @@ QtObject {
}
function showError(type, traceback, sourceIndication="", message="") {
console.error(`python: ${sourceIndication}\n${traceback}`)
if (window.hideErrorTypes.has(type)) {
console.info("Not showing popup for ignored error type " + type)
return
}
utils.makePopup(
"Popups/UnexpectedErrorPopup.qml",
{ errorType: type, message, traceback },
)
}
function sum(array) {
if (array.length < 1) return 0
return array.reduce((a, b) => (isNaN(a) ? 0 : a) + (isNaN(b) ? 0 : b))

View File

@ -24,8 +24,6 @@ ApplicationWindow {
property var history: ({})
property var theme: null
property var hideErrorTypes: new Set(["gaierror", "SSLError"])
readonly property var visibleMenus: ({})
readonly property var visiblePopups: ({})
readonly property bool anyMenu: Object.keys(visibleMenus).length > 0