File tree Expand file tree Collapse file tree 6 files changed +16
-9
lines changed
amazonq/test/unit/amazonqFeatureDev/util
amazonqFeatureDev/session Expand file tree Collapse file tree 6 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -8,15 +8,14 @@ import {
8
8
prepareRepoData ,
9
9
PrepareRepoDataOptions ,
10
10
TelemetryHelper ,
11
- ContentLengthError ,
12
11
maxRepoSizeBytes ,
13
12
} from 'aws-core-vscode/amazonqFeatureDev'
14
13
import { assertTelemetry , getWorkspaceFolder , TestFolder } from 'aws-core-vscode/test'
15
14
import { fs , AmazonqCreateUpload , ZipStream } from 'aws-core-vscode/shared'
16
15
import { MetricName , Span } from 'aws-core-vscode/telemetry'
17
16
import sinon from 'sinon'
18
17
import { CodeWhispererSettings } from 'aws-core-vscode/codewhisperer'
19
- import { CurrentWsFolders } from 'aws-core-vscode/amazonq'
18
+ import { ContentLengthError , CurrentWsFolders } from 'aws-core-vscode/amazonq'
20
19
import path from 'path'
21
20
22
21
const testDevfilePrepareRepo = async ( devfileEnabled : boolean ) => {
Original file line number Diff line number Diff line change 4
4
*
5
5
*/
6
6
7
+ /**
8
+ * Shared error type for content length validation.
9
+ * When thrown from common components, individual agents can catch and transform this error
10
+ * to provide their own customized error messages.
11
+ */
7
12
import { ToolkitError } from '../shared/errors'
8
13
9
- export class CommonAmazonQContentLengthError extends ToolkitError {
14
+ export class ContentLengthError extends ToolkitError {
10
15
constructor ( message : string ) {
11
- super ( message , { code : 'CommonAmazonQContentLengthError ' } )
16
+ super ( message , { code : 'ContentLengthError ' } )
12
17
}
13
18
}
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export { ExtensionMessage } from '../amazonq/webview/ui/commands'
43
43
export { CodeReference } from '../codewhispererChat/view/connector/connector'
44
44
export { extractAuthFollowUp } from './util/authUtils'
45
45
export { Messenger } from './commons/connector/baseMessenger'
46
+ export { ContentLengthError } from './errors'
46
47
import { FeatureContext } from '../shared/featureConfig'
47
48
48
49
/**
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ import { ZipStream } from '../../shared/utilities/zipStream'
28
28
import { isPresent } from '../../shared/utilities/collectionUtils'
29
29
import { AuthUtil } from '../../codewhisperer/util/authUtil'
30
30
import { TelemetryHelper } from '../util/telemetryHelper'
31
- import { CommonAmazonQContentLengthError } from '../errors'
31
+ import { ContentLengthError } from '../errors'
32
32
33
33
export const SvgFileExtension = '.svg'
34
34
@@ -185,9 +185,9 @@ export async function prepareRepoData(
185
185
zipFileChecksum : zipResult . hash ,
186
186
}
187
187
} catch ( error ) {
188
- getLogger ( ) . debug ( `featureDev: Failed to prepare repo: ${ error } ` )
188
+ getLogger ( ) . debug ( `Failed to prepare repo: ${ error } ` )
189
189
if ( error instanceof ToolkitError && error . code === 'ContentLengthError' ) {
190
- throw new CommonAmazonQContentLengthError ( error . message )
190
+ throw new ContentLengthError ( error . message )
191
191
}
192
192
throw new PrepareRepoFailedError ( )
193
193
}
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import globals from '../../shared/extensionGlobals'
31
31
import { extensionVersion } from '../../shared/vscode/env'
32
32
import { getLogger } from '../../shared/logger/logger'
33
33
import { ContentLengthError } from '../errors'
34
- import { CommonAmazonQContentLengthError } from '../../amazonq/errors'
34
+ import { ContentLengthError as CommonAmazonQContentLengthError } from '../../amazonq/errors'
35
35
36
36
export class Session {
37
37
private _state ?: SessionState | Omit < SessionState , 'uploadId' >
@@ -153,6 +153,7 @@ export class Session {
153
153
return resp . interaction
154
154
} catch ( e ) {
155
155
if ( e instanceof CommonAmazonQContentLengthError ) {
156
+ getLogger ( ) . debug ( `Content length validation failed: ${ e . message } ` )
156
157
throw new ContentLengthError ( )
157
158
}
158
159
throw e
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ import { UpdateAnswerMessage } from '../../amazonq/commons/connector/connectorMe
33
33
import { FollowUpTypes } from '../../amazonq/commons/types'
34
34
import { SessionConfig } from '../../amazonq/commons/session/sessionConfigFactory'
35
35
import { Messenger } from '../../amazonq/commons/connector/baseMessenger'
36
- import { CommonAmazonQContentLengthError } from '../../amazonq/errors'
36
+ import { ContentLengthError as CommonAmazonQContentLengthError } from '../../amazonq/errors'
37
37
export class Session {
38
38
private _state ?: SessionState | Omit < SessionState , 'uploadId' >
39
39
private task : string = ''
@@ -160,6 +160,7 @@ export class Session {
160
160
return resp . interaction
161
161
} catch ( e ) {
162
162
if ( e instanceof CommonAmazonQContentLengthError ) {
163
+ getLogger ( ) . debug ( `Content length validation failed: ${ e . message } ` )
163
164
throw new ContentLengthError ( )
164
165
}
165
166
throw e
You can’t perform that action at this time.
0 commit comments