From ac891d603d34fdfd27fdee7ce3bdee14d17f0a55 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 20 Jan 2021 15:17:42 +0100 Subject: [PATCH] Error Handling Improved for command app.update --- Client/httpInterface.js | 46 +++++++++++++--- .../Docs-Concepts/backup-entity - Copy.json | 13 ----- ...ds-errors-003-app-error-update-failed.json | 52 +++++++++++++++++++ ...rs-001-ts-task-error-unexpected-error.json | 20 +++++-- .../UI/Spaces/Docs-Space/CommandInterface.js | 9 +++- 5 files changed, 116 insertions(+), 24 deletions(-) delete mode 100644 Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json diff --git a/Client/httpInterface.js b/Client/httpInterface.js index 253b4e4a1..3b00911b9 100644 --- a/Client/httpInterface.js +++ b/Client/httpInterface.js @@ -666,7 +666,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> err.stack = ' + err.stack) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> commitMessage = ' + commitMessage) console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> username = ' + username) - console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') + console.log('[ERROR] httpInterface -> App -> Contribute -> doGithub -> token starts with = ' + token.substring(0, 10) + '...') 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) @@ -699,16 +699,49 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE update() async function update() { - let message = await doGit() + let result = await doGit() - if (message !== undefined) { + if (result.error === undefined) { let customResponse = { result: global.CUSTOM_OK_RESPONSE.result, - message: message + message: result.message } respondWithContent(JSON.stringify(customResponse), httpResponse) } else { - respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), httpResponse) + + let docs = { + project: 'Superalgos', + category: 'Topic', + type: 'App Error - Update Failed', + anchor: 'Anchor Update Failed', + 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 + } + } + + let customResponse = { + result: global.CUSTOM_FAIL_RESPONSE.result, + docs: docs + } + + respondWithContent(JSON.stringify(customResponse), httpResponse) } } @@ -724,10 +757,11 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE let message try { message = await git.pull('https://github.com/Superalgos/Superalgos', currentBranch) - return message + return { message: message } } catch (err) { console.log('[ERROR] Error updating ' + currentBranch) console.log(err.stack) + return { error: err } } } diff --git a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json b/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json deleted file mode 100644 index 62e7d7d82..000000000 --- a/Projects/Superalgos/Schemas/Docs-Concepts/backup-entity - Copy.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "type": "Backup Entity CONFLICT CREATED", - "definition": { - "text": "Downloads a JSON file with the entity, which may be to whole Workspace or a node, including references concerning the particular node and its offspring. Use this feature to save your entire workspace or any particular structure of nodes within your workspace so that you may later restore the information, including all references, should you need to. For your reference, the file downloaded is named Backup followed by the name of the entity you are backing up.", - "updated": 1610032969934 - }, - "paragraphs": [ - { - "style": "Text", - "text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode." - } - ] -} \ 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 8dec6fa21..d76237dc6 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 @@ -11,6 +11,58 @@ "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 + }, + { + "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": 1611151375974 + }, + { + "style": "Subtitle", + "text": "Error Message" + }, + { + "style": "Text", + "text": "The following is the Error Message of the Exception that occured at the Client:", + "updated": 1611151299633 + }, + { + "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:", + "updated": 1611151427220 + }, + { + "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:", + "updated": 1611151443562 + }, + { + "style": "Placeholder", + "text": "errorCode" } ] } \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json b/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json index 69e29808e..31430900c 100644 --- a/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json +++ b/Projects/Superalgos/Schemas/Docs-Topics/ts-task-errors-001-ts-task-error-unexpected-error.json @@ -16,8 +16,20 @@ }, { "style": "Title", - "text": "Error Message", - "updated": 1610971316249 + "text": "Error Details", + "updated": 1611151211050 + }, + { + "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." + }, + { + "style": "Subtitle", + "text": "Error Message" }, { "style": "Text", @@ -30,7 +42,7 @@ "updated": 1610971337737 }, { - "style": "Title", + "style": "Subtitle", "text": "Error Stack", "updated": 1610968600444 }, @@ -45,7 +57,7 @@ "updated": 1610968640796 }, { - "style": "Title", + "style": "Subtitle", "text": "Error Code" }, { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 638d1ed0e..3d462383b 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -136,7 +136,14 @@ function newSuperalgosDocsCommmandInterface() { UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Message - Update Done - Already Up-To-Date') } } else { - UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'App Error - Update Failed', 'Anchor Update Failed') + UI.projects.superalgos.spaces.docsSpace.navigateTo( + data.docs.project, + data.docs.category, + data.docs.type, + data.docs.anchor, + undefined, + data.docs.placeholder + ) } } }