Ejemplo n.º 1
0
        static void FillLogException(Exception actualException, object entity, Exception initialException)
        {
            if (entity == null)
            {
                actualException.AndLabel("no-entity");
            }
            else
            {
                actualException.AndFactIs("Entity type", entity.GetType().FullName);

                if (entity is LogEntity le)
                {
                    if (le.Labels != null && le.Labels.Count != 0)
                    {
                        actualException.AndFactIs("Labels",
                                                  string.Join(", ", le.Labels.Select(l => $"{l.Key}={l.Value}")));
                    }
                    else
                    {
                        actualException.AndLabel("no-labels");
                    }

                    if (le.Message != null)
                    {
                        actualException.AndFactIs("Log message", le.Message);
                    }
                    else
                    {
                        actualException.AndLabel("no-message");
                    }

                    if (le.Facts != null && le.Facts.Count != 0)
                    {
                        actualException.AndFactIs("Facts", le.Facts.Select(f => $"{f.Key}={f.Value}"));
                    }
                    else
                    {
                        actualException.AndLabel("no-facts");
                    }
                }
            }

            if (initialException == null)
            {
                actualException.AndLabel("no-exception");
            }
            else
            {
                actualException
                .AndFactIs("Exception type", initialException.GetType().FullName)
                .AndFactIs("Exception message", initialException.Message);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds fact about ES call into exception
 /// </summary>
 public static Exception AndFactIs(this Exception exception, IApiCallDetails apiCallDetails)
 {
     return(exception.AndFactIs("es-call-details",
                                apiCallDetails != null
             ? ApiCallDumper.ApiCallToDump(apiCallDetails)
             : "[null]"));
 }