@@ -73,7 +73,7 @@ import { ChatSessionManagementService } from '../chat/chatSessionManagementServi
7373import { ChatTelemetryController } from '../chat/telemetry/chatTelemetryController'
7474import { QuickAction } from '../chat/quickActions'
7575import { Metric } from '../../shared/telemetry/metric'
76- import { getErrorMessage , getHttpStatusCode , isAwsError , isNullish , isObject } from '../../shared/utils'
76+ import { getErrorMessage , getHttpStatusCode , getRequestID , isAwsError , isNullish , isObject } from '../../shared/utils'
7777import { HELP_MESSAGE , loadingMessage } from '../chat/constants'
7878import { TelemetryService } from '../../shared/telemetry/telemetryService'
7979import {
@@ -120,7 +120,7 @@ import {
120120 responseTimeoutPartialMsg ,
121121} from './constants'
122122import { URI } from 'vscode-uri'
123- import { AgenticChatError , customerFacingErrorCodes } from './errors'
123+ import { AgenticChatError , customerFacingErrorCodes , unactionableErrorCodes } from './errors'
124124
125125type ChatHandlers = Omit <
126126 LspHandlers < Chat > ,
@@ -1554,22 +1554,22 @@ export class AgenticChatController implements ChatHandlers {
15541554 tabId : string ,
15551555 metric : Metric < CombinedConversationEvent >
15561556 ) : ChatResult | ResponseError < ChatResult > {
1557- let errorMessage : string | undefined
1558- let requestID : string | undefined
1559- if ( isAwsError ( err ) || ( isObject ( err ) && typeof getHttpStatusCode ( err ) === 'number' ) ) {
1560- if ( err instanceof CodeWhispererStreamingServiceException ) {
1561- errorMessage = err . message
1562- requestID = err . $metadata . requestId
1563- } else if ( err ?. cause ?. message ) {
1564- errorMessage = err ?. cause ?. message
1565- requestID = err . cause ?. $metadata . requestId
1566- } else if ( err instanceof Error || err ?. message ) {
1567- errorMessage = err . message
1568- }
1557+ const errorMessage = getErrorMessage ( err )
1558+ const requestID = getRequestID ( err ) ?? ''
1559+ metric . setDimension ( 'cwsprChatResponseCode' , getHttpStatusCode ( err ) ?? 0 )
1560+ metric . setDimension ( 'languageServerVersion' , this . #features. runtime . serverInfo . version )
15691561
1570- metric . setDimension ( 'cwsprChatResponseCode' , getHttpStatusCode ( err ) ?? 0 )
1571- metric . setDimension ( 'languageServerVersion' , this . #features. runtime . serverInfo . version )
1572- this . #telemetryController. emitMessageResponseError ( tabId , metric . metric , requestID , errorMessage )
1562+ // use custom error message for unactionable errors (user-dependent errors like PromptCharacterLimit)
1563+ if ( err . code && err . code in unactionableErrorCodes ) {
1564+ const customErrMessage = unactionableErrorCodes [ err . code as keyof typeof unactionableErrorCodes ]
1565+ this . #telemetryController. emitMessageResponseError ( tabId , metric . metric , requestID , customErrMessage )
1566+ } else {
1567+ this . #telemetryController. emitMessageResponseError (
1568+ tabId ,
1569+ metric . metric ,
1570+ requestID ,
1571+ errorMessage ?? genericErrorMsg
1572+ )
15731573 }
15741574
15751575 let authFollowType : ReturnType < typeof getAuthFollowUpType > = undefined
0 commit comments