UNPKG

@broadcom/ca7-for-zowe-cli

Version:

CA 7 Workload Automation Plug-in for Zowe CLI

50 lines 2.31 kB
"use strict"; /* * Copyright © 202X Broadcom Inc. and/or its subsidiaries * © 202X Broadcom Inc and/or its subsidiaries; All rights reserved */ Object.defineProperty(exports, "__esModule", { value: true }); exports.CA7RestClient = void 0; const imperative_1 = require("@zowe/imperative"); class CA7RestClient extends imperative_1.RestClient { /** * Use the Zowe logger instead of the imperative logger * @type {Logger} */ get log() { return imperative_1.Logger.getAppLogger(); } /** * Process an error encountered in the rest client * @param {IImperativeError} original - the original error automatically built by the abstract rest client * @returns {IImperativeError} - the processed error with details added * @memberof CA7RestClient */ processError(original) { original.msg = "CA7 REST API Error:\n" + original.msg; let details = original.causeErrors; try { const json = JSON.parse(details); // if we didn't get an error trying to parse json, check if there is a stack // on the JSON error and delete it if (json.stack != undefined || json.stack != null) { this.log.error("An error was encountered in CA7REST with a stack." + "Here is the full error before deleting the stack:\n%s", JSON.stringify(json)); this.log.error("The stack has been deleted from the error before displaying the error to the user"); delete json.stack; // remove the stack field } // if we didn't get an error, make the parsed details part of the error json.message = json.message.replace(/ +/g, " "); json.message = json.message.split(";").join("\n\t"); details = imperative_1.TextUtils.prettyJson(json, undefined, true); } catch (e) { // if there's an error, the causeErrors text is not json this.log.debug("Encountered an error trying to parse causeErrors as JSON - causeErrors is likely not JSON format"); } original.msg += "\n" + details; // add the data string which is the original error return original; } } exports.CA7RestClient = CA7RestClient; //# sourceMappingURL=CA7RestClient.js.map