mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-29 17:06:35 +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
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]
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue