QML Utils.showError() function

This commit is contained in:
miruka 2020-03-15 15:40:53 -04:00
parent de729e42d9
commit 7fd41f3eb4
2 changed files with 23 additions and 18 deletions

View File

@ -29,25 +29,11 @@ QtObject {
if (type === "CancelledError") return
if (onError) {
onError(type, args, error, traceback)
return
}
onError ?
onError(type, args, error, traceback, uuid) :
utils.showError(type, traceback, uuid)
console.error(`python: ${uuid}\n${traceback}`)
if (window.hideErrorTypes.has(type)) {
console.warn(
"Not showing error popup for this type due to user choice"
)
return
}
utils.makePopup(
"Popups/UnexpectedErrorPopup.qml",
window,
{ errorType: type, traceback },
)
return
}
if (onSuccess) onSuccess(result)

View File

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