Exemple #1
0
        private static void WriteException(this IObjectWriter writer, Exception exception, Action <IObjectWriter> objectWriter)
        {
            objectWriter?.Invoke(writer);

            if (exception != null)
            {
                writer.WriteException(exception);
            }
        }
Exemple #2
0
        private static void WriteException <T>(this IObjectWriter writer, Exception exception, T context, Action <T, IObjectWriter> objectWriter)
        {
            objectWriter?.Invoke(context, writer);

            if (exception != null)
            {
                writer.WriteException(exception);
            }
        }
Exemple #3
0
 private static void InternalWriteException(IObjectWriter writer, Exception exception)
 {
     writer.WriteProperty("message", exception.Message)
     .WriteProperty("type", exception.GetType().FullName)
     .WriteProperty("stacktrace", exception.StackTrace);
     if (exception is AggregateException aggregateException)
     {
         writer.WriteArray("inner_exceptions", array =>
         {
             foreach (Exception innerException in aggregateException.InnerExceptions)
             {
                 array.WriteObject(x => InternalWriteException(x, innerException));
             }
         });
     }
     else if (exception.InnerException != null)
     {
         writer.WriteException(exception.InnerException, "inner_exception");
     }
 }