@@ -96,6 +96,7 @@ async function traceLSPPerformance(javaExt: vscode.Extension<any>) {
9696 if ( traceEvent . error ) {
9797 let code : number = traceEvent . error ?. code || 0 ;
9898 let errorMessage : string = traceEvent . error ?. message || String ( traceEvent . error ) ;
99+ let exception : string = "" ;
99100 if ( code === CANCELLATION_CODE || code === CONTENT_MODIFIED_CODE ) {
100101 return ;
101102 }
@@ -104,8 +105,11 @@ async function traceLSPPerformance(javaExt: vscode.Extension<any>) {
104105 // lsp4j will wrap the error message as "Internal error."
105106 // when it encounters an uncaught exception from jdt language server.
106107 if ( code === INTERNAL_ERROR_CODE ) {
107- const actualCause = resolveActualCause ( traceEvent . error . data ) ;
108- errorMessage = actualCause ? errorMessage + " " + actualCause : errorMessage ;
108+ const originalException = resolveActualCause ( traceEvent . error . data ) ;
109+ if ( originalException ) {
110+ errorMessage = errorMessage + " " + originalException . message ;
111+ exception = originalException . stack . join ( "\n" ) ;
112+ }
109113 }
110114
111115 sendInfo ( "" , {
@@ -114,6 +118,7 @@ async function traceLSPPerformance(javaExt: vscode.Extension<any>) {
114118 duration : Math . trunc ( traceEvent . duration ) ,
115119 code,
116120 message : errorMessage ,
121+ exception,
117122 javaversion : javaExtVersion ,
118123 remark : sampling ,
119124 } ) ;
@@ -204,7 +209,12 @@ function escapeLspRequestName(name: string) {
204209 return name . replace ( / \/ / g, "-" )
205210}
206211
207- function resolveActualCause ( callstack : any ) : string | undefined {
212+ interface Exception {
213+ message : string ;
214+ stack : string [ ] ;
215+ }
216+
217+ function resolveActualCause ( callstack : any ) : Exception | undefined {
208218 if ( ! callstack ) {
209219 return ;
210220 }
@@ -213,7 +223,10 @@ function resolveActualCause(callstack: any): string | undefined {
213223 if ( callstacks ?. length ) {
214224 for ( let i = callstacks . length - 1 ; i >= 0 ; i -- ) {
215225 if ( callstacks [ i ] ?. startsWith ( "Caused by:" ) ) {
216- return callstacks [ i ] ;
226+ return {
227+ message : callstacks [ i ] ,
228+ stack : callstacks . slice ( i ) ,
229+ } ;
217230 }
218231 }
219232 }
0 commit comments