From eb1ad95d66c5f511b74bfa2b484fdcb842eb8e0b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:37:30 +0100 Subject: [PATCH] This is my contribution to Superalgos --- Client/httpInterface.js | 94 ++++++++++++------- ...s-001-app-error-contribution-not-sent.json | 57 ++++++++++- ...ds-errors-003-app-error-update-failed.json | 4 +- .../UI/Spaces/Docs-Space/CommandInterface.js | 9 +- 4 files changed, 125 insertions(+), 39 deletions(-) diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 3b00911b9..c871fc884 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -599,12 +599,34 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE contribute() async function contribute() { - if (await doGit() === false) { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + let error + error = 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) + + error = await doGithub() + if (error !== undefined) { + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Contribution Not Sent', + anchor: undefined, + placeholder: {} + } + + respondWithDocsObject(docs, result.error) return } respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse) @@ -623,14 +645,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 + return err } } @@ -657,10 +678,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 +690,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 + return err } } } @@ -713,35 +733,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) } } @@ -831,6 +828,35 @@ 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 + } + } + + 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..c9d083363 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,61 @@ "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 Details" + }, + { + "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": "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..55523747f 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,8 +9,8 @@ "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", 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 + ) } } }