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,27 +29,13 @@ QtObject {
if (type === "CancelledError") return if (type === "CancelledError") return
if (onError) { onError ?
onError(type, args, error, traceback) onError(type, args, error, traceback, uuid) :
utils.showError(type, traceback, uuid)
return return
} }
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 },
)
}
if (onSuccess) onSuccess(result) 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) { 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))