UNPKG

@broadcom/jclcheck-for-zowe-cli

Version:

JCLCheck Plug-in for Zowe CLI

66 lines 3.14 kB
"use strict"; /** * Copyright (c) 2023. Broadcom. All rights reserved. * * This software and all information contained therein is confidential and * proprietary and shall not be duplicated, used, disclosed or disseminated * in any way except as authorized by the applicable license agreement, * without the express written permission of BROADCOM. All authorized reproductions * must be marked with this language. * * EXCEPT AS SET FORTH IN THE APPLICABLE LICENSE AGREEMENT, TO THE EXTENT * PERMITTED BY APPLICABLE LAW, BROADCOM PROVIDES THIS SOFTWARE WITHOUT * WARRANTY OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED * WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN * NO EVENT WILL BROADCOM BE LIABLE TO THE END USER OR ANY THIRD PARTY FOR ANY * LOSS OR DAMAGE, DIRECT OR INDIRECT, FROM THE USE OF THIS SOFTWARE, * INCLUDING WITHOUT LIMITATION, LOST PROFITS, BUSINESS INTERRUPTION, * GOODWILL, OR LOST DATA, EVEN IF CA IS EXPRESSLY ADVISED OF SUCH LOSS OR * DAMAGE. * * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. * **/ Object.defineProperty(exports, "__esModule", { value: true }); exports.JCLCheckRestClient = void 0; const imperative_1 = require("@zowe/imperative"); class JCLCheckRestClient 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 ZosmfRestClient */ processError(original) { original.msg = "z/OSMF 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 != null) { this.log.error("An error was encountered in z/OSMF 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 details = imperative_1.TextUtils.prettyJson(json, undefined, false); } 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.JCLCheckRestClient = JCLCheckRestClient; //# sourceMappingURL=JCLCheckRestClient.js.map