public async handleOnUpdateConfiguration()

in server/aws-lsp-codewhisperer/src/shared/amazonQServiceManager/AmazonQTokenServiceManager.ts [150:185]


    public async handleOnUpdateConfiguration(params: UpdateConfigurationParams, _token: CancellationToken) {
        try {
            if (params.section === Q_CONFIGURATION_SECTION && params.settings.profileArn !== undefined) {
                const profileArn = params.settings.profileArn

                if (!isStringOrNull(profileArn)) {
                    throw new Error('Expected params.settings.profileArn to be of either type string or null')
                }

                this.log(`Profile update is requested for profile ${profileArn}`)
                this.cancelActiveProfileChangeToken()
                this.profileChangeTokenSource = new CancellationTokenSource()

                await this.handleProfileChange(profileArn, this.profileChangeTokenSource.token)
            }
        } catch (error) {
            this.log('Error updating profiles: ' + error)
            if (error instanceof AmazonQServiceProfileUpdateCancelled) {
                throw new ResponseError(LSPErrorCodes.ServerCancelled, error.message, {
                    awsErrorCode: error.code,
                })
            }
            if (error instanceof AmazonQError) {
                throw new ResponseError(LSPErrorCodes.RequestFailed, error.message, {
                    awsErrorCode: error.code,
                })
            }

            throw new ResponseError(LSPErrorCodes.RequestFailed, 'Failed to update configuration')
        } finally {
            if (this.profileChangeTokenSource) {
                this.profileChangeTokenSource.dispose()
                this.profileChangeTokenSource = undefined
            }
        }
    }