Skip to content

Commit 1d78a6f

Browse files
committed
Implement specific error handling for API Payload Too Large errors HTTP 413
1 parent a70ad37 commit 1d78a6f

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export const dictionary = {
208208
ERROR_DURING_REFACTORING: (file_path: string) =>
209209
`An error occurred during refactoring ${file_path}. See console for details.`,
210210
API_RATE_LIMIT_EXCEEDED: 'API request failed. Rate limit exceeded.',
211+
API_PAYLOAD_TOO_LARGE: 'API request failed. The context is too large.',
211212
API_BAD_REQUEST: 'API request failed. Bad request.',
212213
API_ENDPOINT_UNAVAILABLE:
213214
'Endpoint is currently unable to handle the request. Wait a few moments and retry or use another API provider.',

‎packages/vscode/src/utils/make-api-request.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ export const make_api_request = async (params: {
384384
vscode.window.showErrorMessage(
385385
dictionary.error_message.API_RATE_LIMIT_EXCEEDED
386386
)
387+
} else if (axios.isAxiosError(error) && error.response?.status == 413) {
388+
vscode.window.showErrorMessage(
389+
dictionary.error_message.API_PAYLOAD_TOO_LARGE
390+
)
387391
} else if (axios.isAxiosError(error) && error.response?.status == 400) {
388392
vscode.window.showErrorMessage(dictionary.error_message.API_BAD_REQUEST)
389393
} else if (axios.isAxiosError(error) && error.response?.status == 503) {

0 commit comments

Comments
 (0)