@@ -806,11 +806,23 @@ ipcMain.handle('plantuml:render-svg', async (_, diagram: string, format: 'svg' =
806806 errorOutput += chunk . toString ( ) ;
807807 } ) ;
808808
809+ const logPlantumlFailure = ( reason : string , context ?: Record < string , unknown > ) => {
810+ const payload = {
811+ reason,
812+ ...( context ?? { } ) ,
813+ } ;
814+ log . error ( '[PlantUML] Rendering failed' , payload ) ;
815+ } ;
816+
809817 child . on ( 'error' , ( err ) => {
810818 const message =
811819 err instanceof Error
812820 ? err . message
813821 : 'Failed to start the local PlantUML renderer process.' ;
822+ logPlantumlFailure ( 'spawn-error' , {
823+ message,
824+ stderr : errorOutput . trim ( ) || undefined ,
825+ } ) ;
814826 finalize ( {
815827 success : false ,
816828 error : message ,
@@ -825,6 +837,10 @@ ipcMain.handle('plantuml:render-svg', async (_, diagram: string, format: 'svg' =
825837 }
826838
827839 const exitDetails = errorOutput . trim ( ) ;
840+ logPlantumlFailure ( 'non-zero-exit' , {
841+ exitCode : code ?? null ,
842+ stderr : exitDetails || undefined ,
843+ } ) ;
828844 finalize ( {
829845 success : false ,
830846 error : derivePlantumlFriendlyError ( exitDetails , code ?? undefined ) ,
@@ -834,6 +850,9 @@ ipcMain.handle('plantuml:render-svg', async (_, diagram: string, format: 'svg' =
834850
835851 child . stdin . on ( 'error' , ( err ) => {
836852 const message = err instanceof Error ? err . message : String ( err ) ;
853+ logPlantumlFailure ( 'stdin-error' , {
854+ message,
855+ } ) ;
837856 finalize ( {
838857 success : false ,
839858 error : 'Failed to send diagram to the PlantUML renderer.' ,
@@ -845,7 +864,10 @@ ipcMain.handle('plantuml:render-svg', async (_, diagram: string, format: 'svg' =
845864 } ) ;
846865 } catch ( error ) {
847866 const message = error instanceof Error ? error . message : String ( error ) ;
848- console . error ( 'PlantUML rendering failed:' , error ) ;
867+ log . error ( '[PlantUML] Rendering failed before invoking renderer' , {
868+ message,
869+ error,
870+ } ) ;
849871 return { success : false , error : message } ;
850872 }
851873} ) ;
0 commit comments