mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-23 14:06:28 +02:00
[ui] ErrorHandler: analyse error (only used by computation for now)
This commit is contained in:
parent
95c7a9b87f
commit
78f7febeb7
4 changed files with 49 additions and 20 deletions
|
@ -186,7 +186,9 @@ class TaskManager(BaseObject):
|
||||||
if chunksInConflict:
|
if chunksInConflict:
|
||||||
chunksStatus = set([chunk.status.status.name for chunk in chunksInConflict])
|
chunksStatus = set([chunk.status.status.name for chunk in chunksInConflict])
|
||||||
chunksName = [node.name for node in chunksInConflict]
|
chunksName = [node.name for node in chunksInConflict]
|
||||||
msg = 'TaskManager.compute(): WARNING - Some nodes are already submitted with status: {}\nNodes: {}'.format(
|
# Syntax and terms are used on QML side to recognize the error
|
||||||
|
msg = '[COMPUTATION] Already Submitted:\n' \
|
||||||
|
'WARNING - Some nodes are already submitted with status: {}\nNodes: {}'.format(
|
||||||
', '.join(chunksStatus),
|
', '.join(chunksStatus),
|
||||||
', '.join(chunksName)
|
', '.join(chunksName)
|
||||||
)
|
)
|
||||||
|
|
32
meshroom/ui/qml/Utils/errorHandler.js
Normal file
32
meshroom/ui/qml/Utils/errorHandler.js
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
.pragma library
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analyse raised errors.
|
||||||
|
* Works only if errors are written with this specific syntax:
|
||||||
|
* [Context] ErrorType: ErrorMessage
|
||||||
|
*
|
||||||
|
* Maybe it would be better to handle errors on Python side but it should be harder to handle Dialog customization
|
||||||
|
*/
|
||||||
|
function analyseError(error) {
|
||||||
|
const msg = error.toString()
|
||||||
|
|
||||||
|
// The use of [^] is like . but it takes in count every character including \n (works as a double negation)
|
||||||
|
// Group 1: Context
|
||||||
|
// Group 2: ErrorType
|
||||||
|
// Group 3: ErrorMessage
|
||||||
|
const regex = /\[(.*)\]\s(.*):([^]*)/
|
||||||
|
if(!regex.test(msg))
|
||||||
|
return {
|
||||||
|
context: "",
|
||||||
|
type: "",
|
||||||
|
msg: ""
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = regex.exec(msg)
|
||||||
|
|
||||||
|
return {
|
||||||
|
context: data[1],
|
||||||
|
type: data[2],
|
||||||
|
msg: data[3].startsWith("\n") ? data[3].slice(1) : data[3]
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ singleton Colors 1.0 Colors.qml
|
||||||
SortFilterDelegateModel 1.0 SortFilterDelegateModel.qml
|
SortFilterDelegateModel 1.0 SortFilterDelegateModel.qml
|
||||||
Request 1.0 request.js
|
Request 1.0 request.js
|
||||||
Format 1.0 format.js
|
Format 1.0 format.js
|
||||||
|
ErrorHandler 1.0 errorHandler.js
|
||||||
# using singleton here causes random crash at application exit
|
# using singleton here causes random crash at application exit
|
||||||
# singleton Clipboard 1.0 Clipboard.qml
|
# singleton Clipboard 1.0 Clipboard.qml
|
||||||
# singleton Filepath 1.0 Filepath.qml
|
# singleton Filepath 1.0 Filepath.qml
|
||||||
|
|
|
@ -166,9 +166,9 @@ ApplicationWindow {
|
||||||
_reconstruction.execute(node)
|
_reconstruction.execute(node)
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
let msg = error.toString()
|
const data = ErrorHandler.analyseError(error)
|
||||||
msg = msg.split("Error: ")[1] // Remove the QML prefix
|
if(data.context === "COMPUTATION")
|
||||||
computeErrorDialog.openError(msg, node)
|
computeErrorDialog.openError(data.type, data.msg, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,29 +180,26 @@ ApplicationWindow {
|
||||||
MessageDialog {
|
MessageDialog {
|
||||||
id: computeErrorDialog
|
id: computeErrorDialog
|
||||||
|
|
||||||
property int errorId // Used to specify signals' behavior
|
property string errorType // Used to specify signals' behavior
|
||||||
property var currentNode: null
|
property var currentNode: null
|
||||||
|
|
||||||
function openError(msg, node) {
|
function openError(type, msg, node) {
|
||||||
// Open specific dialog if the error is related to the following method
|
errorType = type
|
||||||
// There is maybe a better way to handle this
|
switch(type) {
|
||||||
if(msg.startsWith("TaskManager.compute()"))
|
case "Already Submitted": this.setupPendingStatusError(msg, node); break
|
||||||
this.setupPendingStatusError(msg, node)
|
default: this.onlyDisplayError(msg)
|
||||||
else
|
}
|
||||||
this.onlyDisplayError(msg)
|
|
||||||
|
|
||||||
this.open()
|
this.open()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onlyDisplayError(msg) {
|
function onlyDisplayError(msg) {
|
||||||
errorId = 0
|
|
||||||
text = msg
|
text = msg
|
||||||
|
|
||||||
standardButtons = Dialog.Ok
|
standardButtons = Dialog.Ok
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupPendingStatusError(msg, node) {
|
function setupPendingStatusError(msg, node) {
|
||||||
errorId = 1
|
|
||||||
currentNode = node
|
currentNode = node
|
||||||
text = msg + "\n\nDo you want to Clear Pending Status and Start Computing?"
|
text = msg + "\n\nDo you want to Clear Pending Status and Start Computing?"
|
||||||
|
|
||||||
|
@ -217,17 +214,14 @@ ApplicationWindow {
|
||||||
text: ""
|
text: ""
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
switch(errorId) {
|
switch(errorType) {
|
||||||
case 0: {
|
case "Already Submitted": {
|
||||||
close()
|
|
||||||
break
|
|
||||||
}
|
|
||||||
case 1: {
|
|
||||||
close()
|
close()
|
||||||
_reconstruction.graph.clearSubmittedNodes()
|
_reconstruction.graph.clearSubmittedNodes()
|
||||||
_reconstruction.execute(currentNode)
|
_reconstruction.execute(currentNode)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
default: close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue