diff --git a/packages/cli/lang/en.lyaml b/packages/cli/lang/en.lyaml index 676978750..0501affd0 100644 --- a/packages/cli/lang/en.lyaml +++ b/packages/cli/lang/en.lyaml @@ -1271,6 +1271,7 @@ en: standardErrors: errorOccurred: "Error: {{ error }}" errorContext: "Context: {{ context }}" + errorCause: "Cause: {{ cause }}" systemErrorOccurred: "A system error has occurred: {{ errorMessage }}" genericErrorOccurred: "A {{ name }} has occurred." unknownErrorOccurred: "An unknown error has occurred" diff --git a/packages/cli/lib/errorHandlers/standardErrors.js b/packages/cli/lib/errorHandlers/standardErrors.js index 92751b67e..66995c5fb 100644 --- a/packages/cli/lib/errorHandlers/standardErrors.js +++ b/packages/cli/lib/errorHandlers/standardErrors.js @@ -1,3 +1,4 @@ +const util = require('util'); const { HubSpotAuthError } = require('@hubspot/cli-lib/lib/models/Errors'); const { logger } = require('@hubspot/cli-lib/logger'); const { i18n } = require('../lang'); @@ -40,7 +41,18 @@ function debugErrorAndContext(error, context) { } else { logger.debug(i18n(`${i18nKey}.errorOccurred`, { error })); } - logger.debug(i18n(`${i18nKey}.errorContext`, { context })); + if (error.cause) { + logger.debug( + i18n(`${i18nKey}.errorCause`, { + cause: util.inspect(error.cause, false, null, true), + }) + ); + } + logger.debug( + i18n(`${i18nKey}.errorContext`, { + context: util.inspect(context, false, null, true), + }) + ); } /**