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

View file

@ -1,13 +0,0 @@
1.6.0.0:
Added JSON data format
Old one should still work
1.6.1.0:
Changed server domain name
Fixed not found data file "brick"
1.6.1.5:
Question answering/getting/parsing improvements
Passive mode
1.6.1.6:
Fixed question saving match percent
1.6.2.0:
Document element getting refactoring

51
main.js
View file

@ -855,24 +855,8 @@ function Main () {
ShowMessage({ ShowMessage({
m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!', m: 'Fatál error. Check console (f12). Kattints az üzenetre az összes kérdés/válaszért manuális kereséshez!',
isSimple: true isSimple: true
}, undefined, function () { }, undefined, () => {
let path = 'lred' OpenErrorPage(e)
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
})
}) })
Exception(e, 'script error at main:') Exception(e, 'script error at main:')
@ -1228,7 +1212,7 @@ function HandleQuiz () {
if (r !== undefined) { answers.push(r) } if (r !== undefined) { answers.push(r) }
HighLightAnswer(result, j) // highlights the answer for the current result HighLightAnswer(result, j) // highlights the answer for the current result
} }
ShowAnswers(answers) ShowAnswers(answers, q.q)
} }
function PrepareAnswers (result, j) { function PrepareAnswers (result, j) {
@ -1254,7 +1238,7 @@ function PrepareAnswers (result, j) {
} }
} }
function ShowAnswers (answers) { function ShowAnswers (answers, question) {
assert(answers) assert(answers)
if (answers.length > 0) { // if there are more than 0 answer 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.', 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 isSimple: true
}, undefined, function () { }, undefined, function () {
openInTab(serverAdress + 'lred', { OpenErrorPage({
active: true message: 'No result found',
stack: question // TODO: test this
}) })
}) })
} }
@ -2198,6 +2183,28 @@ var assert = (val) => {
if (!val) { throw new Error('Assertion failed') } 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 {{{ // : Help {{{