MXS-1300: Improve MaxCtrl HTTP error messages
The messages now show where the request failed and what was requested. This should help resolve both develper and end-user problems. Also fixed the missing logging of the output string in the `parse` callback of the main function and cleaned up the POSTed server body.
This commit is contained in:
@ -171,8 +171,16 @@ exports.builder = function(yargs) {
|
|||||||
getDifference(src.servers.data, dest.servers.data).forEach(function(i) {
|
getDifference(src.servers.data, dest.servers.data).forEach(function(i) {
|
||||||
// Create the servers without relationships, those are generated when services and
|
// Create the servers without relationships, those are generated when services and
|
||||||
// monitors are updated
|
// monitors are updated
|
||||||
delete i.relationships
|
var newserv = {
|
||||||
promises.push(doAsyncRequest(host, 'servers', null, {method: 'POST', body: {data: i}}))
|
data: {
|
||||||
|
id: i.id,
|
||||||
|
type: i.type,
|
||||||
|
attributes: {
|
||||||
|
parameters: i.attributes.parameters
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promises.push(doAsyncRequest(host, 'servers', null, {method: 'POST', body: newserv}))
|
||||||
})
|
})
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
.then(function() {
|
.then(function() {
|
||||||
|
@ -195,9 +195,9 @@ module.exports = function() {
|
|||||||
}
|
}
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
if (err.response && err.response.body) {
|
if (err.response && err.response.body) {
|
||||||
return error('Server responded with status code ' + err.statusCode + ' to `' + err.response.request.method +' ' + resource + '`:' + JSON.stringify(err.response.body, null, 4))
|
return error('Server at '+ err.response.request.uri.host +' responded with status code ' + err.statusCode + ' to `' + err.response.request.method +' ' + resource + '`:' + JSON.stringify(err.response.body, null, 4))
|
||||||
} else if (err.statusCode) {
|
} else if (err.statusCode) {
|
||||||
return error('Server responded with status code ' + err.statusCode + ' to `' + err.response.request.method +' ' + resource + '`')
|
return error('Server at '+ err.response.request.uri.host +' responded with status code ' + err.statusCode + ' to `' + err.response.request.method +' ' + resource + '`')
|
||||||
} else if (err.error) {
|
} else if (err.error) {
|
||||||
return error(JSON.stringify(err.error, null, 4))
|
return error(JSON.stringify(err.error, null, 4))
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,7 +100,9 @@ module.exports.execute = function(argv, opts) {
|
|||||||
program
|
program
|
||||||
.parse(argv, {resolve: resolve, reject: reject}, function(err, argv, output) {
|
.parse(argv, {resolve: resolve, reject: reject}, function(err, argv, output) {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err)
|
reject(err.message)
|
||||||
|
} else if (output) {
|
||||||
|
logger.log(output)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user