From 9c7abfc943a08e205aff07d643c685633cf7c858 Mon Sep 17 00:00:00 2001 From: Andrew Twydell Date: Mon, 6 Jan 2025 15:57:05 +0000 Subject: [PATCH] error handling to catch certificate issues Signed-off-by: Andrew Twydell --- packages/vsce/src/utils/profileManagement.ts | 39 +++++++++++++++----- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/packages/vsce/src/utils/profileManagement.ts b/packages/vsce/src/utils/profileManagement.ts index e8c01bfc..05062400 100644 --- a/packages/vsce/src/utils/profileManagement.ts +++ b/packages/vsce/src/utils/profileManagement.ts @@ -106,6 +106,13 @@ export class ProfileManagement { if (`${error.mDetails.errorCode}` === "404") { return null; } + window.showErrorMessage( + `${error.causeErrors.code} - ${error.causeErrors.message}`, + ); + } else { + window.showErrorMessage( + `Error getting CICSCICSPlex resource - ${JSON.stringify(error)}`, + ); } throw error; } @@ -202,15 +209,29 @@ export class ProfileManagement { }); } } else { - // TODO: Error checking!! - const singleRegion = await getResource(session, { - name: "CICSRegion", - }); - infoLoaded.push({ - plexname: null, - regions: toArray(singleRegion.response.records.cicsregion), - group: false, - }); + try { + const singleRegion = await getResource(session, { + name: "CICSRegion", + }); + infoLoaded.push({ + plexname: null, + regions: toArray(singleRegion.response.records.cicsregion), + group: false, + }); + } catch (error) { + if (error instanceof imperative.RestClientError) { + if (`${error.mDetails.errorCode}` === "404") { + window.showErrorMessage( + `CMCI Endpoint not found - ${error.mDetails.protocol}://${error.mDetails.host}:${error.mDetails.port}${error.mDetails.resource}`, + ); + } + } else { + window.showErrorMessage( + `Error making request - ${JSON.stringify(error)}`, + ); + } + throw error; + } } return infoLoaded;