Skip to content

Commit 52411fd

Browse files
committed
fix(amazonq): allow for more iterations on prompt related errors
1 parent 22af3f8 commit 52411fd

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

packages/core/src/amazonqDoc/errors.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ import { ToolkitError } from '../shared/errors'
77
import { i18n } from '../shared/i18n-helper'
88

99
export class DocServiceError extends ToolkitError {
10-
remainingIterations: number
11-
constructor(message: string, code: string, remainingIterations: number) {
10+
remainingIterations?: number
11+
constructor(message: string, code: string, remainingIterations?: number) {
1212
super(message, { code })
1313
this.remainingIterations = remainingIterations
1414
}
1515
}
1616

1717
export class ReadmeTooLargeError extends DocServiceError {
18-
constructor(remainingIterations: number) {
19-
super(i18n('AWS.amazonq.doc.error.readmeTooLarge'), ReadmeTooLargeError.name, remainingIterations)
18+
constructor() {
19+
super(i18n('AWS.amazonq.doc.error.readmeTooLarge'), ReadmeTooLargeError.name)
2020
}
2121
}
2222

@@ -27,18 +27,14 @@ export class ReadmeUpdateTooLargeError extends DocServiceError {
2727
}
2828

2929
export class WorkspaceEmptyError extends DocServiceError {
30-
constructor(remainingIterations: number) {
31-
super(i18n('AWS.amazonq.doc.error.workspaceEmpty'), WorkspaceEmptyError.name, remainingIterations)
30+
constructor() {
31+
super(i18n('AWS.amazonq.doc.error.workspaceEmpty'), WorkspaceEmptyError.name)
3232
}
3333
}
3434

3535
export class NoChangeRequiredException extends DocServiceError {
36-
constructor(remainingIterations: number) {
37-
super(
38-
i18n('AWS.amazonq.doc.error.noChangeRequiredException'),
39-
NoChangeRequiredException.name,
40-
remainingIterations
41-
)
36+
constructor() {
37+
super(i18n('AWS.amazonq.doc.error.noChangeRequiredException'), NoChangeRequiredException.name)
4238
}
4339
}
4440

@@ -49,8 +45,8 @@ export class PromptRefusalException extends DocServiceError {
4945
}
5046

5147
export class ContentLengthError extends DocServiceError {
52-
constructor(remainingIterations: number) {
53-
super(i18n('AWS.amazonq.doc.error.contentLengthError'), ContentLengthError.name, remainingIterations)
48+
constructor() {
49+
super(i18n('AWS.amazonq.doc.error.contentLengthError'), ContentLengthError.name)
5450
}
5551
}
5652

packages/core/src/amazonqDoc/session/sessionState.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,16 +148,16 @@ abstract class CodeGenBase {
148148
messenger.sendUpdatePromptProgress(this.tabID, null)
149149
switch (true) {
150150
case codegenResult.codeGenerationStatusDetail?.includes('README_TOO_LARGE'): {
151-
throw new ReadmeTooLargeError(codeGenerationRemainingIterationCount)
151+
throw new ReadmeTooLargeError()
152152
}
153153
case codegenResult.codeGenerationStatusDetail?.includes('README_UPDATE_TOO_LARGE'): {
154154
throw new ReadmeUpdateTooLargeError(codeGenerationRemainingIterationCount)
155155
}
156156
case codegenResult.codeGenerationStatusDetail?.includes('WORKSPACE_TOO_LARGE'): {
157-
throw new ContentLengthError(codeGenerationRemainingIterationCount)
157+
throw new ContentLengthError()
158158
}
159159
case codegenResult.codeGenerationStatusDetail?.includes('WORKSPACE_EMPTY'): {
160-
throw new WorkspaceEmptyError(codeGenerationRemainingIterationCount)
160+
throw new WorkspaceEmptyError()
161161
}
162162
case codegenResult.codeGenerationStatusDetail?.includes('PROMPT_UNRELATED'): {
163163
throw new PromptUnrelatedError(codeGenerationRemainingIterationCount)
@@ -177,12 +177,11 @@ abstract class CodeGenBase {
177177
}
178178
case codegenResult.codeGenerationStatusDetail?.includes('EmptyPatch'): {
179179
if (codegenResult.codeGenerationStatusDetail?.includes('NO_CHANGE_REQUIRED')) {
180-
throw new NoChangeRequiredException(codeGenerationRemainingIterationCount)
180+
throw new NoChangeRequiredException()
181181
}
182182
throw new DocServiceError(
183183
i18n('AWS.amazonq.doc.error.docGen.default'),
184-
'EmptyPatchException',
185-
codeGenerationRemainingIterationCount
184+
'EmptyPatchException'
186185
)
187186
}
188187
case codegenResult.codeGenerationStatusDetail?.includes('Throttling'): {

0 commit comments

Comments
 (0)