@broadcom/sysview-for-zowe-cli
Version:
Zowe CLI plugin for SYSVIEW
64 lines • 2.96 kB
JavaScript
;
/*
* Copyright (c) 2020 Broadcom. All Rights Reserved. The term
* "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
*
* 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 BROADCOM IS
* EXPRESSLY ADVISED OF SUCH LOSS OR DAMAGE.
*
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SysviewRestClient = void 0;
const imperative_1 = require("@zowe/imperative");
/**
* Sysview specific server implementations
*
* @export
* @class SysviewRestClient
* @extends {RestClient}
*/
class SysviewRestClient extends imperative_1.RestClient {
/**
* 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 SysviewRestClient
*/
processError(original) {
try {
// if causeErrors is json, pretty print it
const json = JSON.parse(original.causeErrors);
original.causeErrors = imperative_1.TextUtils.prettyJson(json, undefined, false, "");
}
catch (e) { /* not json */ }
original.msg = `SYSVIEW REST API Error:\n${original.msg}\n`;
if (this.response && this.response.statusCode === imperative_1.RestConstants.HTTP_STATUS_401) {
original.msg +=
this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_BASIC ?
"Username or password are not valid or expired.\n" :
this.session.ISession.type === imperative_1.SessConstants.AUTH_TYPE_TOKEN ?
"Token is not valid or expired.\n\nFor CLI usage, see `zowe auth login apiml --help`\n" : "";
}
else if (this.response && this.response.statusCode === imperative_1.RestConstants.HTTP_STATUS_500) {
original.additionalDetails = "SYSVIEW encountered an error processing the request.\n\n" + original.causeErrors;
}
return original;
}
}
exports.SysviewRestClient = SysviewRestClient;
//# sourceMappingURL=SysviewRestClient.js.map