Skip to content

Instantly share code, notes, and snippets.

@npearce
Last active July 31, 2018 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npearce/fde5cfa422897bea144f50095f9cabde to your computer and use it in GitHub Desktop.
Save npearce/fde5cfa422897bea144f50095f9cabde to your computer and use it in GitHub Desktop.
F5 iControl LX - How to access additional error response data (lines 25 & 26)
/**
* Apply the new, or modified, service definition to the BIG-IP
* @param {Object} service_def retireved from GitHub repo
*
* @returns {Object} AS3's declaration processing results
*/
MyWorker.prototype.applyServiceDefinition = function (service_def) {
return new Promise((resolve, reject) => {
// Build the declaration POST message
var as3path = '/mgmt/shared/appsvcs/declare';
var uri = this.restHelper.makeRestnodedUri(as3path);
var restOp = this.createRestOperation(uri, service_def);
// Send the declaration POST message to the BIG-IP
this.restRequestSender.sendPost(restOp)
.then((resp) => {
resolve(resp.body.results);
})
.catch((err) => {
let errorStatusCode = err.getResponseOperation().getStatusCode();
let errorBody = JSON.stringify(err.getResponseOperation().getBody(), '', '\t');
logger.info('[MyWorker - ERROR] - applyServiceDefinition(): ' +errorStatusCode+ ':\n' +errorBody);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment