Merge pull request #427 from Luis-Fernando-Molina/develop

Contribution: Swithching Branches Error Handling Improved, with Docs and Placeholders
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2021-01-20 16:38:58 +01:00
commit 2e3c667459
5 files changed
+99 -27

No files matched your search

+14 -7
View File
@@ -612,7 +612,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
}
respondWithDocsObject(docs, result.error)
return
}
@@ -629,7 +628,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
console.log('respond with docs ')
respondWithDocsObject(docs, error)
return
}
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
@@ -786,15 +784,25 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
case 'Checkout': {
try {
const currentBranch = unescape(requestParameters[3])
let error
checkout()
async function checkout() {
let result = await doGit()
await doGit()
if (result === true) {
if (error === undefined) {
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
} else {
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse)
let docs = {
project: 'Superalgos',
category: 'Topic',
type: 'Switching Branches - Current Branch Not Changed',
anchor: undefined,
placeholder: {}
}
respondWithDocsObject(docs, error)
}
}
@@ -811,9 +819,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
} catch (err) {
console.log('[ERROR] Error changing current branch to ' + currentBranch)
console.log(err.stack)
return false
error = err
}
return true
}
} catch (err) {
@@ -7,10 +7,75 @@
"updated": 1610543788194
},
"paragraphs": [
{
"style": "Text",
"text": "More detailed info of what caused this failure to switch can be found below.",
"updated": 1611155878425
},
{
"style": "Title",
"text": "Error Info"
},
{
"style": "Text",
"text": "In the following section you will find the specific information received when this error occured."
},
{
"style": "Note",
"text": "More detailed info of what caused this failure to switch can be find at the Client's Console.",
"updated": 1610543823314
"text": "You will only see it if you opened this page as a result of the error actually happening.",
"updated": 1611155956953
},
{
"style": "Subtitle",
"text": "Error Message"
},
{
"style": "Text",
"text": "The following is the Error Message of the Exception that occured at the Client:"
},
{
"style": "Placeholder",
"text": "errorMessage"
},
{
"style": "Subtitle",
"text": "Error Stack"
},
{
"style": "Text",
"text": "The following is the Error Stack of the Exception that occured at the Client:"
},
{
"style": "Placeholder",
"text": "errorStack"
},
{
"style": "Subtitle",
"text": "Error Code"
},
{
"style": "Text",
"text": "The follwing is the Error Code of the Exception that occured at the Client:"
},
{
"style": "Placeholder",
"text": "errorCode"
},
{
"style": "Subtitle",
"text": "Error Details"
},
{
"style": "Text",
"text": "The follwing are all the Error details of the Exception that occured at the Client:"
},
{
"style": "Placeholder",
"text": "errorDetails"
},
{
"style": "Text",
"text": ""
}
]
}
@@ -21,7 +21,7 @@ function newSuperalgosDocSpace() {
paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials, Reviews or Books Schema in order to find it when we need to update them.
textArea: undefined,
changeLanguage: changeLanguage,
changeActiveBranch: changeActiveBranch,
changeCurrentBranch: changeCurrentBranch,
changeContributionsBranch: changeContributionsBranch,
enterEditMode: enterEditMode,
exitEditMode: exitEditMode,
@@ -183,7 +183,7 @@ function newSuperalgosDocSpace() {
initialize()
}
function changeActiveBranch(branch) {
function changeCurrentBranch(branch) {
httpRequest(undefined, 'App/Checkout/' + branch, onResponse)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Changing Current Branch')
@@ -195,7 +195,14 @@ function newSuperalgosDocSpace() {
window.localStorage.setItem('Current Branch', branch)
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Current Branch Changed')
} else {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Switching Branches - Current Branch Not Changed')
UI.projects.superalgos.spaces.docsSpace.navigateTo(
data.docs.project,
data.docs.category,
data.docs.type,
data.docs.anchor,
undefined,
data.docs.placeholder
)
}
}
}
@@ -476,13 +476,13 @@ function newSuperalgosDocsDocumentPage() {
case "Placeholder": {
renderParagraph(paragraph, key)
editableParagraphIndex++
let error = addPlaceholdedParagraph(paragraph.text)
if (error !== undefined) {
let result = addPlaceholdedParagraph(paragraph.text)
if (result !== undefined) {
paragraph = {
style: "Error",
text: error
style: "Note",
text: result
}
key = 'error-paragraph-' + autoGeneratedParagraphIndex
key = 'note-paragraph-' + autoGeneratedParagraphIndex
renderParagraph(paragraph, key)
autoGeneratedParagraphIndex++
}
@@ -622,14 +622,7 @@ function newSuperalgosDocsDocumentPage() {
autoGeneratedParagraphIndex++
return
} else {
let paragraph = {
type: "Json",
text: JSON.stringify(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.placeholder, undefined, 4)
}
let key = 'placeholded-paragraph-' + autoGeneratedParagraphIndex
renderParagraph(paragraph, key)
autoGeneratedParagraphIndex++
return 'Property ' + propertyName + ' not found at the placeholder object.'
return 'Property ' + propertyName + ' not found at the placeholder object. This means that within the info recieved, this information is not available.'
}
}
}
@@ -98,8 +98,8 @@ function newSuperalgosDocsFooter() {
HTML = HTML + '<h4>Choose the Current Branch</h4>'
HTML = HTML + 'You are currently running on the <code class="docs-footer-code">' + UI.projects.superalgos.utilities.gitBranches.getBranchLabel(UI.projects.superalgos.spaces.docsSpace.currentBranch) + '</code> branch. Switch to:'
HTML = HTML + '<ul>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeActiveBranch(\'master\')">Master</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeActiveBranch(\'develop\')">Develop</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeCurrentBranch(\'master\')">Master</a></li>'
HTML = HTML + '<li><a href="#" onClick="UI.projects.superalgos.spaces.docsSpace.changeCurrentBranch(\'develop\')">Develop</a></li>'
HTML = HTML + '</ul>'
HTML = HTML + '</div>'