Skip to content

Commit

Permalink
Merge pull request #1776 from zowe/confusing-error-messages
Browse files Browse the repository at this point in the history
Improve activation errors and team config logging
  • Loading branch information
zFernand0 committed May 6, 2022
2 parents 1c4e1a9 + 29e16ce commit c178df0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions packages/zowe-explorer/i18n/sample/src/extension.i18n.json
@@ -1,6 +1,7 @@
{
"initialize.log.debug": "Initialized logger from VSCode extension",
"initialize.log.error": "Error encountered while activating and initializing logger! ",
"initialize.profiles.error": "Error reading or initializing Zowe CLI profiles.",
"createNewConnection.option.prompt.profileName.placeholder": "Connection Name",
"createNewConnection.option.prompt.profileName": "Enter a name for the connection.",
"createNewConnection.undefined.passWord": "Operation Cancelled",
Expand Down
40 changes: 20 additions & 20 deletions packages/zowe-explorer/src/extension.ts
Expand Up @@ -70,25 +70,23 @@ export async function activate(context: vscode.ExtensionContext): Promise<ZoweEx

hideTempFolder(getZoweDir());

try {
if (!fs.existsSync(globals.ZOWETEMPFOLDER)) {
fs.mkdirSync(globals.ZOWETEMPFOLDER);
fs.mkdirSync(globals.ZOWE_TMP_FOLDER);
fs.mkdirSync(globals.USS_DIR);
fs.mkdirSync(globals.DS_DIR);
}
} catch (err) {
await errorHandling(err, null, err.message);
}

let datasetProvider: IZoweTree<IZoweDatasetTreeNode>;
let ussFileProvider: IZoweTree<IZoweUSSTreeNode>;
let jobsProvider: IZoweTree<IZoweJobTreeNode>;

try {
globals.initLogger(context);
globals.LOG.debug(localize("initialize.log.debug", "Initialized logger from VSCode extension"));
} catch (err) {
const errorMessage = localize(
"initialize.log.error",
"Error encountered while activating and initializing logger! "
);
await errorHandling(err, null, errorMessage);
globals.LOG.error(errorMessage + JSON.stringify(err));
}

try {
// Ensure that ~/.zowe folder exists
if (!ImperativeConfig.instance.config?.exists) {
await CliProfileManager.initialize({
Expand All @@ -102,23 +100,25 @@ export async function activate(context: vscode.ExtensionContext): Promise<ZoweEx
// Initialize profile manager
await Profiles.createInstance(globals.LOG);

if (!fs.existsSync(globals.ZOWETEMPFOLDER)) {
fs.mkdirSync(globals.ZOWETEMPFOLDER);
fs.mkdirSync(globals.ZOWE_TMP_FOLDER);
fs.mkdirSync(globals.USS_DIR);
fs.mkdirSync(globals.DS_DIR);
}

// Initialize dataset provider
datasetProvider = await createDatasetTree(globals.LOG);
// Initialize uss provider
ussFileProvider = await createUSSTree(globals.LOG);
// Initialize Jobs provider with the created session and the selected pattern
jobsProvider = await createJobsTree(globals.LOG);
} catch (err) {
await errorHandling(
err,
null,
localize("initialize.log.error", "Error encountered while activating and initializing logger! ")
);
globals.LOG.error(
localize("initialize.log.error", "Error encountered while activating and initializing logger! ") +
JSON.stringify(err)
);
const errorMessage = localize("initialize.profiles.error", "Error reading or initializing Zowe CLI profiles.");
await errorHandling(err, null, errorMessage);
globals.LOG.error(errorMessage + JSON.stringify(err));
}

// set a command to silently reload extension
context.subscriptions.push(
vscode.commands.registerCommand("zowe.extRefresh", async () => {
Expand Down
22 changes: 20 additions & 2 deletions packages/zowe-explorer/src/utils/ProfilesUtils.ts
Expand Up @@ -14,8 +14,8 @@
import * as vscode from "vscode";
import * as fs from "fs";
import * as globals from "../globals";
import { Session, IProfile, IProfileLoaded, ProfileInfo, Logger } from "@zowe/imperative";
import { getSecurityModules, IZoweTreeNode, ProfilesCache, ZoweTreeNode, getZoweDir } from "@zowe/zowe-explorer-api";
import { Session, IProfile, IProfileLoaded, ProfileInfo, IConfigLayer } from "@zowe/imperative";
import { getSecurityModules, IZoweTreeNode, ZoweTreeNode, getZoweDir } from "@zowe/zowe-explorer-api";
import { Profiles } from "../Profiles";
import * as nls from "vscode-nls";

Expand Down Expand Up @@ -247,5 +247,23 @@ export async function readConfigFromDisk() {
}
if (mProfileInfo.usingTeamConfig) {
globals.setConfigPath(rootPath);
globals.LOG.debug(
'Zowe Explorer is using the team configuration file "%s"',
mProfileInfo.getTeamConfig().configName
);
const layers = mProfileInfo.getTeamConfig().layers || [];
const layerSummary = layers.map(
(config: IConfigLayer) =>
`Path: ${config.path}: ${
config.exists
? "Found, with the following defaults:" +
JSON.stringify(config.properties?.defaults || "Undefined default")
: "Not available"
} `
);
globals.LOG.debug(
"Summary of team configuration files considered for Zowe Explorer: %s",
JSON.stringify(layerSummary)
);
}
}

0 comments on commit c178df0

Please sign in to comment.