@@ -62,7 +62,7 @@ export class WriteFile implements Tool<FileWriteResult> {
62
62
// First validate the overall structure
63
63
const validation = this . _validateDiffBlock ( diff ) ;
64
64
if ( ! validation . isValid ) {
65
- this . context . logger . error ( "Diff block validation failed:" + { error : validation . error } ) ;
65
+ this . context . logger . error ( "Diff block validation failed:" , { error : validation . error ? { stack : validation . error } : undefined } ) ;
66
66
throw new Error ( `Invalid diff block format: ${ validation . error } ` ) ;
67
67
}
68
68
@@ -163,8 +163,12 @@ export class WriteFile implements Tool<FileWriteResult> {
163
163
diffBlocksApplied = blocks . length ;
164
164
this . context . logger . info ( `Successfully applied ${ diffBlocksApplied } diff blocks to file` ) ;
165
165
} catch ( error ) {
166
- this . context . logger . error ( "Error applying diff blocks:" , { error : error instanceof Error ? error : new Error ( String ( error ) ) } ) ;
167
- throw error ;
166
+ this . context . logger . error ( "Error applying diff blocks:" , {
167
+ error : error instanceof Error ? error : { stack : String ( error ) } ,
168
+ stack : error instanceof Error ? error . stack : undefined ,
169
+ } ) ;
170
+ const typedError = error instanceof Error ? error : new Error ( String ( error || "Unknown error" ) ) ;
171
+ throw typedError ;
168
172
}
169
173
} else {
170
174
// Direct content write - will create new file if doesn't exist
@@ -202,12 +206,15 @@ export class WriteFile implements Tool<FileWriteResult> {
202
206
} ,
203
207
} ;
204
208
} catch ( error ) {
205
- const errorObj = error instanceof Error ? error : new Error ( String ( error ) ) ;
206
- this . context . logger . error ( `File write failed:` , { error : errorObj } ) ;
209
+ const errorObj = error instanceof Error ? error : new Error ( String ( error || "Unknown error" ) ) ;
210
+ this . context . logger . error ( `File write failed:` , {
211
+ error : { stack : errorObj . message } ,
212
+ stack : errorObj . stack ,
213
+ } ) ;
207
214
208
215
return {
209
216
success : false ,
210
- error : errorObj . message ,
217
+ error : errorObj . message || "Unknown error occurred" ,
211
218
metadata : {
212
219
timestamp : Date . now ( ) ,
213
220
toolName : this . name ,
0 commit comments