forked from nkovacic/Sample-ASP.NET-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDebugHelper.cs
More file actions
33 lines (29 loc) · 832 Bytes
/
DebugHelper.cs
File metadata and controls
33 lines (29 loc) · 832 Bytes
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sample.Core.Utilities
{
public class DebugHelper
{
public static int GetExceptionLineNumber(Exception e)
{
if (e != null)
{
var stackTrace = new StackTrace(e, true);
var maxFrameCount = Math.Max(stackTrace.FrameCount, 30);
for (int i = 0; i < stackTrace.FrameCount; i++)
{
var frame = stackTrace.GetFrame(i);
if (frame.GetFileLineNumber() > 0)
{
return frame.GetFileColumnNumber();
}
}
}
return -1;
}
}
}