Error Handling Improved for command app.update
This commit is contained in:
1 parent
c61db756d6
commit
ac891d603d
5 files changed
+116
-24
No files matched your search
+40
-6
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user