99using Microsoft . Extensions . Configuration ;
1010using Microsoft . Extensions . Logging ;
1111using Newtonsoft . Json ;
12+ using Newtonsoft . Json . Linq ;
1213using OmniSharp . Endpoint ;
1314using OmniSharp . Mef ;
1415using OmniSharp . Models . UpdateBuffer ;
@@ -160,6 +161,11 @@ public void Start()
160161 }
161162 catch ( Exception e )
162163 {
164+ if ( e is AggregateException aggregateEx )
165+ {
166+ e = aggregateEx . Flatten ( ) . InnerException ;
167+ }
168+
163169 _writer . WriteLine ( new EventPacket ( )
164170 {
165171 Event = "error" ,
@@ -218,6 +224,11 @@ private async Task HandleRequest(string json, ILogger logger)
218224 }
219225 catch ( Exception e )
220226 {
227+ if ( e is AggregateException aggregateEx )
228+ {
229+ e = aggregateEx . Flatten ( ) . InnerException ;
230+ }
231+
221232 // updating the response object here so that the ResponseStream
222233 // prints the latest state when being closed
223234 response . Success = false ;
@@ -241,7 +252,7 @@ void LogRequest(string json, ILogger logger)
241252 try
242253 {
243254 builder . AppendLine ( "************ Request ************" ) ;
244- builder . Append ( json ) ;
255+ builder . Append ( JToken . Parse ( json ) . ToString ( Formatting . Indented ) ) ;
245256 logger . LogDebug ( builder . ToString ( ) ) ;
246257 }
247258 finally
@@ -256,7 +267,7 @@ void LogResponse(string json, ILogger logger)
256267 try
257268 {
258269 builder . AppendLine ( "************ Response ************ " ) ;
259- builder . Append ( json ) ;
270+ builder . Append ( JToken . Parse ( json ) . ToString ( Formatting . Indented ) ) ;
260271 logger . LogDebug ( builder . ToString ( ) ) ;
261272 }
262273 finally
0 commit comments