Refactored error url generation

This commit is contained in:
MrFry 2019-10-07 11:23:31 +02:00
parent e53ca9d87c
commit ff25bff70e
2 changed files with 29 additions and 35 deletions

51
main.js
View file

@ -855,24 +855,8 @@ function Main () {
ShowMessage({
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
isSimple: true
}, undefined, function () {
let path = 'lred'
try {
if (e.message || e.stack) {
path += '?'
}
if (e.message) {
path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&'
}
if (e.stack) {
path += 'stack:' + SUtils.SimplifyStack(e.stack)
}
} catch (e) {
Exception(e, 'error at setting error stack/msg link')
}
openInTab(serverAdress + path, {
active: true
})
}, undefined, () => {
OpenErrorPage(e)
})
Exception(e, 'script error at main:')
@ -1228,7 +1212,7 @@ function HandleQuiz () {
if (r !== undefined) { answers.push(r) }
HighLightAnswer(result, j) // highlights the answer for the current result
}
ShowAnswers(answers)
ShowAnswers(answers, q.q)
}
function PrepareAnswers (result, j) {
@ -1254,7 +1238,7 @@ function PrepareAnswers (result, j) {
}
}
function ShowAnswers (answers) {
function ShowAnswers (answers, question) {
assert(answers)
if (answers.length > 0) { // if there are more than 0 answer
@ -1264,8 +1248,9 @@ function ShowAnswers (answers) {
m: 'Nincs találat :( Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez! Előfordulhat, hogy a tárgyat nem válsztottad ki a menüben.',
isSimple: true
}, undefined, function () {
openInTab(serverAdress + 'lred', {
active: true
OpenErrorPage({
message: 'No result found',
stack: question // TODO: test this
})
})
}
@ -2198,6 +2183,28 @@ var assert = (val) => {
if (!val) { throw new Error('Assertion failed') }
}
function OpenErrorPage (e) {
let path = 'lred'
try {
if (e.message || e.stack) {
path += '?'
}
if (e.message) {
path += 'msg:' + SUtils.SimplifyQuery(e.message) + '&'
}
if (e.stack) {
path += 'stack:' + SUtils.SimplifyStack(e.stack)
}
path = SUtils.RemoveSpecialChars(path)
} catch (e) {
Exception(e, 'error at setting error stack/msg link')
}
path = path.replace(/ /g, '_')
openInTab(serverAdress + path, {
active: true
})
}
// : }}}
// : Help {{{