Skip to content

Commit

Permalink
update try/catch
Browse files Browse the repository at this point in the history
Signed-off-by: Billie Simmons <[email protected]>
  • Loading branch information
JillieBeanSim committed Jul 25, 2023
1 parent 8314be9 commit 255f498
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions packages/zowe-explorer/src/job/ZoweJobNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export class Job extends ZoweTreeNode implements IZoweJobTreeNode {
* @returns {Promise<IZoweJobTreeNode[]>}
*/
public async getChildren(): Promise<IZoweJobTreeNode[]> {
ZoweLogger.trace("ZoweJobNode.getChildren called.");
const thisSessionNode = this.getSessionNode();
ZoweLogger.trace(`ZoweJobNode.getChildren called for ${String(thisSessionNode.label)}.`);
if (contextually.isSession(this) && !this.filtered) {
return [
new Job(
Expand Down Expand Up @@ -177,7 +178,7 @@ export class Job extends ZoweTreeNode implements IZoweJobTreeNode {
// Fetch jobs under session node
const jobs = await this.getJobs(this._owner, this._prefix, this._searchId, this._jobStatus);

if (!jobs.length) {
if (!jobs || !jobs.length > 0) {
const noJobsNode = new Job(
localize("getChildren.noJobs", "No jobs found"),
vscode.TreeItemCollapsibleState.None,
Expand Down Expand Up @@ -335,12 +336,11 @@ export class Job extends ZoweTreeNode implements IZoweJobTreeNode {
private async getJobs(owner: string, prefix: string, searchId: string, status: string): Promise<zowe.IJob[]> {
ZoweLogger.trace("ZoweJobNode.getJobs called.");
let jobsInternal: zowe.IJob[] = [];
const sessNode = this.getSessionNode();
const cachedProfile = Profiles.getInstance().loadNamedProfile(this.getProfileName());
if (this.searchId.length > 0) {
jobsInternal.push(await ZoweExplorerApiRegister.getJesApi(cachedProfile).getJob(searchId));
} else {
try {
try {
if (this.searchId.length > 0) {
jobsInternal.push(await ZoweExplorerApiRegister.getJesApi(cachedProfile).getJob(searchId));
} else {
if (ZoweExplorerApiRegister.getJesApi(cachedProfile).getJobsByParameters) {
jobsInternal = await ZoweExplorerApiRegister.getJesApi(cachedProfile).getJobsByParameters({
owner,
Expand All @@ -367,11 +367,15 @@ export class Job extends ZoweTreeNode implements IZoweJobTreeNode {
return acc;
}
}, []);
} catch (error) {
await errorHandling(error, this.label, localize("getChildren.error.response", "Retrieving response from ") + `zowe.GetJobs`);
}
return jobsInternal;
} catch (error) {
ZoweLogger.trace("Error getting jobs from Rest API.");
await errorHandling(error, this.label, localize("getChildren.error.response", "Retrieving response from ") + `zowe.GetJobs`);
syncSessionNode(Profiles.getInstance())((profileValue) => ZoweExplorerApiRegister.getJesApi(profileValue).getSession())(

Check warning on line 375 in packages/zowe-explorer/src/job/ZoweJobNode.ts

View check run for this annotation

Codecov / codecov/patch

packages/zowe-explorer/src/job/ZoweJobNode.ts#L373-L375

Added lines #L373 - L375 were not covered by tests
this.getSessionNode()
);
}
return jobsInternal;
}
}

Expand Down

0 comments on commit 255f498

Please sign in to comment.