public static void Wrap(Action action, IExceptionLogInfoResolver exceptionLogInfoResolver = null) { try { action.Invoke(); } catch (Exception ex) { Handle(ex, exceptionLogInfoResolver); } }
public static string Handle(Exception ex, IExceptionLogInfoResolver extraLogInfoResolver = null) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.InnerException); Debug.WriteLine(ex.StackTrace); var fileName = FileName(); File.WriteAllText(fileName + ".txt", "-- Resolved URL: " + ScenarioFixture.Instance.ResolveHostAndPort() + Environment.NewLine + "-- Actual URL: " + ScenarioFixture.Instance.Driver.Url + Environment.NewLine + "-- Exception Message: " + ex.Message + Environment.NewLine + "-- Stacktrace: " + Environment.NewLine + ex.StackTrace + Environment.NewLine + Environment.NewLine + "-- Service log: " + Environment.NewLine + (extraLogInfoResolver ?? new NoLogInfoResolver()).ReadLog()); RemoteWebDriver().GetScreenshot().SaveAsFile(fileName + ".png", ImageFormat.Png); PrintExceptions(); return fileName; }
public static string Handle(Exception ex, IExceptionLogInfoResolver extraLogInfoResolver = null) { Debug.WriteLine(ex.Message); Debug.WriteLine(ex.InnerException); Debug.WriteLine(ex.StackTrace); var fileName = FileName(); File.WriteAllText(fileName + ".txt", "-- Resolved URL: " + ScenarioFixture.Instance.ResolveHostAndPort() + Environment.NewLine + "-- Actual URL: " + ScenarioFixture.Instance.Driver.Url + Environment.NewLine + "-- Exception Message: " + ex.Message + Environment.NewLine + "-- Stacktrace: " + Environment.NewLine + ex.StackTrace + Environment.NewLine + Environment.NewLine + "-- Service log: " + Environment.NewLine + (extraLogInfoResolver ?? new NoLogInfoResolver()).ReadLog()); RemoteWebDriver().GetScreenshot().SaveAsFile(fileName + ".png", ScreenshotImageFormat.Png); PrintExceptions(); return fileName; }