forked from Taritsyn/JavaScriptEngineSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThrowExceptionLogger.cs
More file actions
57 lines (46 loc) · 1.41 KB
/
ThrowExceptionLogger.cs
File metadata and controls
57 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System;
using System.Text;
namespace JavaScriptEngineSwitcher.Tests.Interop.Logging
{
public sealed class ThrowExceptionLogger : ILogger
{
public void Error(string category, string message, string filePath = "",
int lineNumber = 0, int columnNumber = 0, string sourceFragment = "")
{
var errorBuilder = new StringBuilder();
errorBuilder.AppendLine("Category: " + category);
errorBuilder.AppendLine("Message: " + message);
if (!string.IsNullOrWhiteSpace(filePath))
{
errorBuilder.AppendLine("File: " + filePath);
}
if (lineNumber > 0)
{
errorBuilder.AppendLine("Line number: " + lineNumber);
}
if (columnNumber > 0)
{
errorBuilder.AppendLine("Column number: " + columnNumber);
}
if (!string.IsNullOrWhiteSpace(sourceFragment))
{
errorBuilder.AppendLine("Source fragment:" + Environment.NewLine + sourceFragment);
}
string errorMessage = errorBuilder.ToString();
errorBuilder.Clear();
throw new InvalidOperationException(errorMessage);
}
public void Warn(string category, string message,
string filePath = "", int lineNumber = 0, int columnNumber = 0,
string sourceFragment = "")
{ }
public void Debug(string category, string message, string filePath = "")
{ }
public void Info(string category, string message, string filePath = "")
{ }
public override string ToString()
{
return "[throw exception logger]";
}
}
}