Skip to content

Commit 592f36c

Browse files
committed
fix(vsce): Don't swallow errors for createDataset
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
1 parent d302778 commit 592f36c

1 file changed

Lines changed: 14 additions & 39 deletions

File tree

packages/vsce/src/api/SshMvsApi.ts

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
type AttributeInfo,
1818
type DataSetAttributesProvider,
1919
type DsInfo,
20-
Gui,
2120
type IAttributesProvider,
2221
imperative,
2322
type MainframeInteraction,
@@ -285,9 +284,9 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
285284
attributes: datasetAttributes,
286285
});
287286
} catch (error) {
288-
if (error instanceof imperative.ImperativeError) {
289-
Gui.errorMessage(error.additionalDetails);
290-
}
287+
throw error instanceof imperative.ImperativeError
288+
? new Error(`${error.message}\n${error.additionalDetails}`)
289+
: error;
291290
}
292291
return this.buildZosFilesResponse(response, response.success);
293292
}
@@ -296,19 +295,10 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
296295
dataSetName: string,
297296
_options?: zosfiles.IUploadOptions,
298297
): Promise<zosfiles.IZosFilesResponse> {
299-
let response: ds.CreateMemberResponse = { success: false };
300-
try {
301-
response = await (await this.client).ds.createMember({
302-
dsname: dataSetName,
303-
overwrite: true, // Overwrite detection already handled on client side
304-
});
305-
if (!response.success) {
306-
Gui.errorMessage(`Failed to create data set member: ${dataSetName}`);
307-
}
308-
} catch (error) {
309-
Gui.errorMessage(`Failed to create data set member: ${dataSetName}`);
310-
Gui.errorMessage(`Error: ${error}`);
311-
}
298+
const response = await (await this.client).ds.createMember({
299+
dsname: dataSetName,
300+
overwrite: true, // Overwrite detection already handled on client side
301+
});
312302
return this.buildZosFilesResponse(response, response.success);
313303
}
314304

@@ -335,9 +325,7 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
335325
dsnameBefore: currentDataSetName,
336326
dsnameAfter: newDataSetName,
337327
});
338-
return this.buildZosFilesResponse({
339-
success: response.success,
340-
});
328+
return this.buildZosFilesResponse(response, response.success);
341329
}
342330

343331
public async renameDataSetMember(
@@ -350,29 +338,18 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
350338
memberBefore,
351339
memberAfter,
352340
});
353-
return this.buildZosFilesResponse({
354-
success: response.success,
355-
});
341+
return this.buildZosFilesResponse(response, response.success);
356342
}
357343

358344
public async hMigrateDataSet(_dataSetName: string): Promise<zosfiles.IZosFilesResponse> {
359345
throw new Error("Not yet implemented");
360346
}
361347

362348
public async hRecallDataSet(dataSetName: string): Promise<zosfiles.IZosFilesResponse> {
363-
let response: ds.RestoreDatasetResponse = { success: false };
364-
try {
365-
response = await (await this.client).ds.restoreDataset({
366-
dsname: dataSetName,
367-
});
368-
if (!response.success) {
369-
Gui.errorMessage(`Failed to restore dataset ${dataSetName}`);
370-
}
371-
} catch (error) {
372-
Gui.errorMessage(`Failed to restore dataset ${dataSetName}`);
373-
Gui.errorMessage(`Error: ${error}`);
374-
}
375-
return this.buildZosFilesResponse(response);
349+
const response = await (await this.client).ds.restoreDataset({
350+
dsname: dataSetName,
351+
});
352+
return this.buildZosFilesResponse(response, response.success);
376353
}
377354

378355
public async deleteDataSet(
@@ -382,9 +359,7 @@ export class SshMvsApi extends SshCommonApi implements MainframeInteraction.IMvs
382359
const response = await (await this.client).ds.deleteDataset({
383360
dsname: dataSetName,
384361
});
385-
return this.buildZosFilesResponse({
386-
success: response.success,
387-
});
362+
return this.buildZosFilesResponse(response, response.success);
388363
}
389364

390365
// biome-ignore lint/suspicious/noExplicitAny: apiResponse has no strong type

0 commit comments

Comments
 (0)