• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Sholtee / proxygen / 869

25 Nov 2023 07:40AM UTC coverage: 94.839% (-0.2%) from 95.021%
869

push

appveyor

Sholtee
eat IO errors during logging

2499 of 2635 relevant lines covered (94.84%)

5.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.0
/SRC/Private/SourceGenerators/ProxyEmbedderBase.Log.cs
1
/********************************************************************************
2
* ProxyEmbedderBase.Log.cs                                                          *
3
*                                                                               *
4
* Author: Denes Solti                                                           *
5
********************************************************************************/
6
using System;
7
using System.Diagnostics;
8
using System.IO;
9
using System.Threading;
10

11
using static System.Environment;
12

13
namespace Solti.Utils.Proxy.Internals
14
{
15
    internal abstract partial class ProxyEmbedderBase
16
    {
17
        //
18
        // SourceGenerator should reference as few dependencies as possible since dependencies must be bundled
19
        // to our sourcegenerator package. That's the reason behind this primitive logging
20
        //
21

22
        internal protected static string? LogException(Exception ex, in CancellationToken cancellation)
23
        {
6✔
24
            string? logDump = WorkingDirectories.Instance.LogDump;
6✔
25
            if (logDump is not null)
6✔
26
            {
4✔
27
                string logFile = Path.Combine(logDump, $"ProxyGen_{Guid.NewGuid()}.log");
4✔
28

29
                Directory.CreateDirectory(logDump);
4✔
30

31
                try
32
                {
4✔
33
                    using StreamWriter log = File.CreateText(logFile);
4✔
34
                    log.AutoFlush = true;
4✔
35

36
                    for (Exception? current = ex; current is not null; current = current.InnerException)
4✔
37
                    {
4✔
38
                        if (current != ex) log.Write($"{NewLine}->{NewLine}", cancellation: cancellation);
×
39
                        log.Write(current.ToString(), cancellation: cancellation);
4✔
40

41
                        foreach (object? key in current.Data.Keys)
4✔
42
                        {
×
43
                            log.Write($"{NewLine + key}:{NewLine + current.Data[key]}", cancellation: cancellation);
×
44
                        }
×
45
                    }
4✔
46

47
                    return logFile;
4✔
48
                }
49
                catch (IOException exc)
×
50
                {
×
51
                    Trace.TraceWarning($"File ({logFile}) could not be dumped: ${exc.Message}");
52
                }
×
53
            }
×
54
            return null;
6✔
55
        }
6✔
56
    }
57
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc