diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 3b00911b9..abe8f07af 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -595,16 +595,41 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE const token = unescape(requestParameters[5]) const currentBranch = unescape(requestParameters[6]) const contributionsBranch = unescape(requestParameters[7]) + let error contribute() async function contribute() { - if (await doGit() === false) { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + await doGit() + if (error !== undefined) { + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Contribution Not Sent', + anchor: undefined, + placeholder: {} + } + + respondWithDocsObject(docs, result.error) + return } - if (await doGithub() === false) { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + + await doGithub() + if (error !== undefined) { + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Contribution Not Sent', + anchor: undefined, + placeholder: {} + } + console.log('respond with docs ') + + respondWithDocsObject(docs, error) + return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) @@ -623,14 +648,13 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE await git.add('./*') await git.commit(commitMessage) await git.push('origin', currentBranch) - return true } catch (err) { console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> Method call produced an error.') console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGit -> contributionsBranch = ' + contributionsBranch) - return false + error = err } } @@ -657,10 +681,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE head, base, }); - return true } catch (err) { if (err.stack.indexOf('A pull request already exists') >= 0) { - return true + return } else { console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> Method call produced an error.') console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) @@ -670,7 +693,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token ends with = ' + '...' + token.substring(token.length - 10)) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> currentBranch = ' + currentBranch) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> contributionsBranch = ' + contributionsBranch) - return false + error = err } } } @@ -693,6 +716,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE } break } + case 'Update': { try { const currentBranch = unescape(requestParameters[3]) @@ -713,35 +737,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE project: 'Superalgos', category: 'Topic', type: 'App Error - Update Failed', - anchor: 'Anchor Update Failed', + anchor: undefined, placeholder: {} } - if (result.error.message !== undefined) { - docs.placeholder.errorMessage = { - style: 'Error', - text: result.error.message - } - } - if (result.error.stack !== undefined) { - docs.placeholder.errorStack = { - style: 'Javascript', - text: result.error.stack - } - } - if (result.error.code !== undefined) { - docs.placeholder.errorCode = { - style: 'Json', - text: result.error.code - } - } + respondWithDocsObject(docs, result.error) - let customResponse = { - result: global.CUSTOM_FAIL_RESPONSE.result, - docs: docs - } - - respondWithContent(JSON.stringify(customResponse), httpResponse) } } @@ -832,6 +833,41 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE break } } + + function respondWithDocsObject(docs, error) { + + if (error.message !== undefined) { + docs.placeholder.errorMessage = { + style: 'Error', + text: error.message + } + } + if (error.stack !== undefined) { + docs.placeholder.errorStack = { + style: 'Javascript', + text: error.stack + } + } + if (error.code !== undefined) { + docs.placeholder.errorCode = { + style: 'Json', + text: error.code + } + } + + docs.placeholder.errorDetails = { + style: 'Json', + text: JSON.stringify(error, undefined, 4) + } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) + + } } break diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json index 7a4401674..8494a6e76 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-001-app-error-contribution-not-sent.json @@ -9,8 +9,77 @@ "paragraphs": [ { "style": "Text", - "text": "Check for the Client's console for details on what may have happened. After you fix the issue that prevented the App Contribute Command to run, you may try again.", - "updated": 1611129009743 + "text": "Check the following section for details on what may have happened. After you fix the issue that prevented the App Contribute Command to run, you may try again.", + "updated": 1611152997869 + }, + { + "style": "Title", + "text": "Error Info", + "updated": 1611154606702 + }, + { + "style": "Text", + "text": "In the following section you will find the specific information received when this error occured." + }, + { + "style": "Note", + "text": "You will only see it if you opened this page as a result of the error actually happening.", + "updated": 1611153032408 + }, + { + "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", + "updated": 1611154543778 + }, + { + "style": "Text", + "text": "The follwing are all the Error details of the Exception that occured at the Client:", + "updated": 1611154675224 + }, + { + "style": "Placeholder", + "text": "errorDetails", + "updated": 1611154555419 + }, + { + "style": "Text", + "text": "" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json index d76237dc6..797d43d15 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/app-commands-errors-003-app-error-update-failed.json @@ -9,12 +9,13 @@ "paragraphs": [ { "style": "Success", - "text": "Check for the Client's console for details on what may have happened. After you fix the issue, you may try again.", - "updated": 1611129360143 + "text": "Check for the following section for details on what may have happened. After you fix the issue, you may try again.", + "updated": 1611152967185 }, { "style": "Title", - "text": "Error Details" + "text": "Error Info", + "updated": 1611154641024 }, { "style": "Text", @@ -63,6 +64,22 @@ { "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": "" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 3d462383b..cf63a0021 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -82,7 +82,14 @@ function newSuperalgosDocsCommmandInterface() { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Contribution Done') } else { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Contribution Not Sent', 'Anchor Contribution Not Sent') + UI.projects.superalgos.spaces.docsSpace.navigateTo( + data.docs.project, + data.docs.category, + data.docs.type, + data.docs.anchor, + undefined, + data.docs.placeholder + ) } } }