Move hideErrorTypes & showError() to PythonBridge
This commit is contained in:
parent
040e966d27
commit
c813e92ac7
|
@ -57,7 +57,7 @@ HFileDialogOpener {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if (unknown) utils.showError(type, traceback, uuid)
|
if (unknown) py.showError(type, traceback, uuid)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ HBox {
|
||||||
type.startsWith("Matrix") ?
|
type.startsWith("Matrix") ?
|
||||||
text = qsTr("Error contacting server: %1").arg(type) :
|
text = qsTr("Error contacting server: %1").arg(type) :
|
||||||
|
|
||||||
utils.showError(type, traceback, uuid)
|
py.showError(type, traceback, uuid)
|
||||||
|
|
||||||
errorMessage.text = text
|
errorMessage.text = text
|
||||||
})
|
})
|
||||||
|
|
|
@ -33,7 +33,7 @@ SignInBase {
|
||||||
type === "MatrixUserDeactivated" ?
|
type === "MatrixUserDeactivated" ?
|
||||||
txt = qsTr("This account was deactivated") :
|
txt = qsTr("This account was deactivated") :
|
||||||
|
|
||||||
utils.showError(type, traceback, uuid)
|
py.showError(type, traceback, uuid)
|
||||||
|
|
||||||
page.errorMessage.text = txt
|
page.errorMessage.text = txt
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,7 @@ import QtQuick.Controls 2.12
|
||||||
import QtQuick.Layouts 1.12
|
import QtQuick.Layouts 1.12
|
||||||
import "../Base"
|
import "../Base"
|
||||||
import "../Base/Buttons"
|
import "../Base/Buttons"
|
||||||
|
import "../PythonBridge" as PythonBridge
|
||||||
|
|
||||||
HColumnPopup {
|
HColumnPopup {
|
||||||
id: popup
|
id: popup
|
||||||
|
@ -54,8 +55,8 @@ HColumnPopup {
|
||||||
text: qsTr("Hide this type of error until restart")
|
text: qsTr("Hide this type of error until restart")
|
||||||
onCheckedChanged:
|
onCheckedChanged:
|
||||||
checked ?
|
checked ?
|
||||||
window.hideErrorTypes.add(errorType) :
|
PythonBridge.Globals.hideErrorTypes.add(errorType) :
|
||||||
window.hideErrorTypes.delete(errorType)
|
PythonBridge.Globals.hideErrorTypes.delete(errorType)
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import ".."
|
|
||||||
import "../.."
|
import "../.."
|
||||||
|
import ".."
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
signal deviceUpdateSignal(string forAccount)
|
signal deviceUpdateSignal(string forAccount)
|
||||||
|
@ -37,7 +37,7 @@ QtObject {
|
||||||
|
|
||||||
onError ?
|
onError ?
|
||||||
onError(type, args, error, traceback, uuid) :
|
onError(type, args, error, traceback, uuid) :
|
||||||
utils.showError(type, traceback, "", uuid)
|
py.showError(type, traceback, "", uuid)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ QtObject {
|
||||||
function onLoopException(message, error, traceback) {
|
function onLoopException(message, error, traceback) {
|
||||||
// No need to log these here, the asyncio exception handler does it
|
// No need to log these here, the asyncio exception handler does it
|
||||||
const type = py.getattr(py.getattr(error, "__class__"), "__name__")
|
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){
|
function onModelItemSet(syncId, indexThen, indexNow, changedFields){
|
||||||
|
|
|
@ -5,4 +5,5 @@ import QtQuick 2.12
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
readonly property var pendingCoroutines: ({})
|
readonly property var pendingCoroutines: ({})
|
||||||
|
readonly property var hideErrorTypes: new Set(["gaierror", "SSLError"])
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,4 +71,18 @@ Python {
|
||||||
if (callback) { callback(settings, uiState, theme) }
|
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 },
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
function sum(array) {
|
||||||
if (array.length < 1) return 0
|
if (array.length < 1) return 0
|
||||||
return array.reduce((a, b) => (isNaN(a) ? 0 : a) + (isNaN(b) ? 0 : b))
|
return array.reduce((a, b) => (isNaN(a) ? 0 : a) + (isNaN(b) ? 0 : b))
|
||||||
|
|
|
@ -24,8 +24,6 @@ ApplicationWindow {
|
||||||
property var history: ({})
|
property var history: ({})
|
||||||
property var theme: null
|
property var theme: null
|
||||||
|
|
||||||
property var hideErrorTypes: new Set(["gaierror", "SSLError"])
|
|
||||||
|
|
||||||
readonly property var visibleMenus: ({})
|
readonly property var visibleMenus: ({})
|
||||||
readonly property var visiblePopups: ({})
|
readonly property var visiblePopups: ({})
|
||||||
readonly property bool anyMenu: Object.keys(visibleMenus).length > 0
|
readonly property bool anyMenu: Object.keys(visibleMenus).length > 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user