using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace Tango.FSE.Procedures.Helpers { public static class ProcedureExceptionHelper { public static int? GetExceptionLineNumber(Exception ex, ProcedureProject project) { try { Regex regex = new Regex(@"OnExecute\(IProcedureContext context\) in :line (\d+)"); var matches = regex.Matches(ex.ToString()).OfType().ToList(); if (matches.Count > 0) { var match = matches.First(); if (match.Groups.Count > 1) { var line = match.Groups[1].Value; int lineNumber = int.Parse(line) - project.Scripts.Count + 1; return lineNumber; } } } catch { } return null; } } }