@@ -134,44 +134,6 @@ export default class ParticipantController {
134134 return this . _participant ;
135135 }
136136
137- handleError ( err : any , command : string ) : void {
138- let errorCode : string | undefined ;
139- let errorName : ParticipantErrorTypes ;
140- // Making the chat request might fail because
141- // - model does not exist
142- // - user consent not given
143- // - quote limits exceeded
144- if ( err instanceof vscode . LanguageModelError ) {
145- errorCode = err . code ;
146- }
147-
148- if ( err instanceof Error ) {
149- // Unwrap the error if a cause is provided
150- err = err . cause || err ;
151- }
152-
153- const message : string = err . message || err . toString ( ) ;
154-
155- if ( message . includes ( 'off_topic' ) ) {
156- errorName = ParticipantErrorTypes . CHAT_MODEL_OFF_TOPIC ;
157- } else if ( message . includes ( 'Filtered by Responsible AI Service' ) ) {
158- errorName = ParticipantErrorTypes . FILTERED ;
159- } else if ( message . includes ( 'Prompt failed validation' ) ) {
160- errorName = ParticipantErrorTypes . INVALID_PROMPT ;
161- } else {
162- errorName = ParticipantErrorTypes . OTHER ;
163- }
164-
165- this . _telemetryService . track (
166- TelemetryEventTypes . PARTICIPANT_RESPONSE_FAILED ,
167- {
168- command,
169- error_code : errorCode ,
170- error_name : errorName ,
171- }
172- ) ;
173- }
174-
175137 /**
176138 * In order to get access to the model, and to write more messages to the chat after
177139 * an async event that occurs after we've already completed our response, we need
@@ -1222,7 +1184,7 @@ export default class ParticipantController {
12221184 title : 'Exporting code to a playground...' ,
12231185 cancellable : true ,
12241186 } ,
1225- async ( progress , token ) : Promise < string | undefined > => {
1187+ ( progress , token ) : Promise < string | undefined > => {
12261188 token . onCancellationRequested ( async ( ) => {
12271189 await vscode . window . showInformationMessage (
12281190 'The running export to a playground operation was canceled.'
@@ -1263,7 +1225,10 @@ export default class ParticipantController {
12631225
12641226 return true ;
12651227 } catch ( error ) {
1266- this . handleError ( error , 'exportToPlayground' ) ;
1228+ this . _telemetryService . trackCopilotParticipantError (
1229+ error ,
1230+ 'exportToPlayground'
1231+ ) ;
12671232 await vscode . window . showErrorMessage (
12681233 `An error occurred exporting to a playground: ${
12691234 formatError ( error ) . message
@@ -1319,10 +1284,13 @@ Please see our [FAQ](https://www.mongodb.com/docs/generative-ai-faq/) for more i
13191284
13201285 return await this . handleGenericRequest ( ...args ) ;
13211286 }
1322- } catch ( e ) {
1323- this . handleError ( e , request . command || 'generic' ) ;
1287+ } catch ( error ) {
1288+ this . _telemetryService . trackCopilotParticipantError (
1289+ error ,
1290+ request . command || 'generic'
1291+ ) ;
13241292 // Re-throw other errors so they show up in the UI.
1325- throw e ;
1293+ throw error ;
13261294 }
13271295 }
13281296
0 commit comments