From 96f1dd4745074262ee763e5ef4c2a1be7bd0944b Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Wed, 11 Sep 2024 12:54:55 -0600 Subject: [PATCH] fix: update error message for sfdx auth url --- messages/core.md | 4 ++++ src/org/authInfo.ts | 10 ++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/messages/core.md b/messages/core.md index 93dfba317e..0113814213 100644 --- a/messages/core.md +++ b/messages/core.md @@ -34,6 +34,10 @@ Errors encountered: Error authenticating with the refresh token due to: %s +# invalidSfdxAuthUrlError + +Invalid SFDX auth URL. Must be in the format "force://::@". Note that the "instanceUrl" inside the SFDX auth URL doesn\'t include a protocol ("https://"). + # orgDataNotAvailableError An attempt to refresh the authentication token failed with a 'Data Not Found Error'. The org identified by username %s does not appear to exist. Likely cause is that the org was deleted by another user or has expired. diff --git a/src/org/authInfo.ts b/src/org/authInfo.ts index b407e0169e..df7cc5d5a5 100644 --- a/src/org/authInfo.ts +++ b/src/org/authInfo.ts @@ -367,10 +367,7 @@ export class AuthInfo extends AsyncOptionalCreatable { ); if (!match) { - throw new SfError( - 'Invalid SFDX auth URL. Must be in the format "force://::@". Note that the SFDX auth URL uses the "force" protocol, and not "http" or "https". Also note that the "instanceUrl" inside the SFDX auth URL doesn\'t include the protocol ("https://").', - 'INVALID_SFDX_AUTH_URL' - ); + throw new SfError(messages.getMessage('invalidSfdxAuthUrlError'), 'INVALID_SFDX_AUTH_URL'); } const [, clientId, clientSecret, refreshToken, loginUrl] = match; return { @@ -1073,8 +1070,9 @@ export class AuthInfo extends AsyncOptionalCreatable { let authFieldsBuilder: TokenResponse; try { authFieldsBuilder = await oauth2.refreshToken(ensure(fullOptions.refreshToken)); - } catch (err) { - throw messages.createError('refreshTokenAuthError', [(err as Error).message]); + } catch (err: unknown) { + const cause = err instanceof Error ? err : SfError.wrap(err); + throw messages.createError('refreshTokenAuthError', [cause.message], undefined, cause); } // eslint-disable-next-line @typescript-eslint/ban-ts-comment