@@ -48,6 +48,7 @@ import {
4848 DEBUG_ENABLED ,
4949 MAX_MESSAGE_LENGTH ,
5050} from "../../../client/src/debug_enabled.mjs" ;
51+ import { ResultErrTypes } from "../../../client/src/rust-types/ResultErrTypes" ;
5152
5253// Globals
5354// -----------------------------------------------------------------------------
@@ -325,10 +326,9 @@ export const activate = (context: vscode.ExtensionContext) => {
325326 value as UpdateMessageContents ;
326327 const doc = get_document ( current_update . file_path ) ;
327328 if ( doc === undefined ) {
328- sendResult (
329- id ,
330- `No open document for ${ current_update . file_path } ` ,
331- ) ;
329+ sendResult ( id , {
330+ NoOpenDocument : current_update . file_path ,
331+ } ) ;
332332 break ;
333333 }
334334 if ( current_update . contents !== undefined ) {
@@ -357,10 +357,7 @@ export const activate = (context: vscode.ExtensionContext) => {
357357 assert ( "Diff" in source ) ;
358358 // If this diff was not made against the text we currently have, reject it.
359359 if ( source . Diff . version !== version ) {
360- sendResult (
361- id ,
362- "Out of sync: incorrect version for diff." ,
363- ) ;
360+ sendResult ( id , "OutOfSync" ) ;
364361 // Send an `Update` with the full text to re-sync the Client.
365362 send_update ( true ) ;
366363 break ;
@@ -454,10 +451,12 @@ export const activate = (context: vscode.ExtensionContext) => {
454451 current_file ,
455452 ) ;
456453 } catch ( e ) {
457- sendResult (
458- id ,
459- `Error: unable to open file ${ current_file } : ${ e } ` ,
460- ) ;
454+ sendResult ( id , {
455+ OpenFileFailed : [
456+ current_file ,
457+ ( e as Error ) . toString ( ) ,
458+ ] ,
459+ } ) ;
461460 continue ;
462461 }
463462 ignore_active_editor_change = true ;
@@ -491,10 +490,12 @@ export const activate = (context: vscode.ExtensionContext) => {
491490 . then (
492491 ( ) => sendResult ( id ) ,
493492 ( reason ) =>
494- sendResult (
495- id ,
496- `Error: unable to open file ${ current_file } : ${ reason } ` ,
497- ) ,
493+ sendResult ( id , {
494+ OpenFileFailed : [
495+ current_file ,
496+ reason ,
497+ ] ,
498+ } ) ,
498499 ) ;
499500 }
500501 sendResult ( id ) ;
@@ -581,12 +582,12 @@ const format_struct = (complex_data_structure: any): string =>
581582 : "" ;
582583
583584// Send a result (a response to a message from the server) back to the server.
584- const sendResult = ( id : number , result : string | null = null ) => {
585+ const sendResult = ( id : number , result : ResultErrTypes | null = null ) => {
585586 assert ( codeChatEditorServer ) ;
586587 console_log (
587588 `CodeChat Editor extension: sending Result(id = ${ id } , ${ format_struct ( result ) } ).` ,
588589 ) ;
589- codeChatEditorServer . sendResult ( id , result ) ;
590+ codeChatEditorServer . sendResult ( id , JSON . stringify ( result ) ) ;
590591} ;
591592
592593// This is called after an event such as an edit, when the CodeChat panel
0 commit comments