@@ -30,6 +30,8 @@ import fs from '../../shared/fs/fs'
3030import globals from '../../shared/extensionGlobals'
3131import { extensionVersion } from '../../shared/vscode/env'
3232import { getLogger } from '../../shared/logger/logger'
33+ import { ContentLengthError } from '../errors'
34+ import { ContentLengthError as FeatureDevContentLengthError } from '../../amazonqFeatureDev/errors'
3335
3436export class Session {
3537 private _state ?: SessionState | Omit < SessionState , 'uploadId' >
@@ -126,28 +128,35 @@ export class Session {
126128 return this . nextInteraction ( msg , mode , folderPath )
127129 }
128130 private async nextInteraction ( msg : string , mode : Mode , folderPath ?: string ) {
129- const resp = await this . state . interact ( {
130- task : this . task ,
131- msg,
132- fs : this . config . fs ,
133- mode : mode ,
134- folderPath : folderPath ,
135- messenger : this . messenger ,
136- telemetry : this . telemetry ,
137- tokenSource : this . state . tokenSource ,
138- uploadHistory : this . state . uploadHistory ,
139- } )
131+ try {
132+ const resp = await this . state . interact ( {
133+ task : this . task ,
134+ msg,
135+ fs : this . config . fs ,
136+ mode : mode ,
137+ folderPath : folderPath ,
138+ messenger : this . messenger ,
139+ telemetry : this . telemetry ,
140+ tokenSource : this . state . tokenSource ,
141+ uploadHistory : this . state . uploadHistory ,
142+ } )
143+
144+ if ( resp . nextState ) {
145+ if ( ! this . state ?. tokenSource ?. token . isCancellationRequested ) {
146+ this . state ?. tokenSource ?. cancel ( )
147+ }
140148
141- if ( resp . nextState ) {
142- if ( ! this . state ?. tokenSource ?. token . isCancellationRequested ) {
143- this . state ?. tokenSource ?. cancel ( )
149+ // Move to the next state
150+ this . _state = resp . nextState
144151 }
145152
146- // Move to the next state
147- this . _state = resp . nextState
153+ return resp . interaction
154+ } catch ( e ) {
155+ if ( e instanceof FeatureDevContentLengthError ) {
156+ throw new ContentLengthError ( )
157+ }
158+ throw e
148159 }
149-
150- return resp . interaction
151160 }
152161
153162 public async updateFilesPaths (
0 commit comments