From 0cf2ef766dd91bcd030ab3e6b8a94da36beee73c Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Wed, 15 Nov 2023 16:44:54 -0700 Subject: [PATCH 1/2] fix: add the original error stack to the new error --- src/commands/org/login/web.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/commands/org/login/web.ts b/src/commands/org/login/web.ts index 090bc9a2..c16d90b7 100644 --- a/src/commands/org/login/web.ts +++ b/src/commands/org/login/web.ts @@ -116,9 +116,13 @@ export default class LoginWeb extends AuthBaseCommand { return fields; } catch (err) { const error = err as Error; - Logger.childFromRoot('auth').debug(error); + Logger.childFromRoot('LoginWebCommand').debug(error); if (error.name === 'AuthCodeExchangeError') { - throw new SfError(messages.getMessage('invalidClientId', [error.message])); + const authError = new SfError(messages.getMessage('invalidClientId', [error.message])); + if (error.stack) { + authError.stack += `\nDUE TO:\n${error.stack}`; + } + throw authError; } throw error; } From 267aa4927f8977776c13c3e0e335d24ef8765616 Mon Sep 17 00:00:00 2001 From: Steve Hetzel Date: Thu, 16 Nov 2023 12:09:46 -0700 Subject: [PATCH 2/2] fix: add a caused by error --- src/commands/org/login/web.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/commands/org/login/web.ts b/src/commands/org/login/web.ts index c16d90b7..adf0ccdc 100644 --- a/src/commands/org/login/web.ts +++ b/src/commands/org/login/web.ts @@ -118,11 +118,7 @@ export default class LoginWeb extends AuthBaseCommand { const error = err as Error; Logger.childFromRoot('LoginWebCommand').debug(error); if (error.name === 'AuthCodeExchangeError') { - const authError = new SfError(messages.getMessage('invalidClientId', [error.message])); - if (error.stack) { - authError.stack += `\nDUE TO:\n${error.stack}`; - } - throw authError; + throw new SfError(messages.getMessage('invalidClientId', [error.message]), undefined, undefined, error); } throw error; }