Ejemplo n.º 1
0
        public override void Process(step context)
        {
            status status = (Throwable != null &&
                             Throwable.GetType().ToString().Contains("Assert"))
                ? status.failed
                : status.broken;

            context.status = status;
        }
        /// <summary>
        /// Build and send report for Exception
        /// </summary>
        /// <param name="th">Throwable that caused exception</param>
        public void ProcessException(Throwable th)
        {
            Log.Error(Constants.LOG_TAG, "Caught a " + th.GetType().Name + " exception for " + _context.PackageName + ". Start building report.");

            var data = ReportDataFactory.BuildReportData(_context, _reportFields, _appStartDate,
                                                         _initialConfiguration, th,
                                                         _interactionMode == InteractionMode.Silent);

            Parallel.ForEach(_customReportDataProviders, s =>
            {
                try
                {
                    var cdata = s.GetReportData(_context);
                    foreach (var d in cdata)
                    {
                        data.Add(d);
                    }
                }
                catch (Exception e)
                {
                    Log.Error(Constants.LOG_TAG, Throwable.FromException(e), "Error getting custom data from " + s.GetType().Name);
                }
            });

            Log.Debug(Constants.LOG_TAG, "Start sending report");
            Parallel.ForEach(_reportSenders, s =>
            {
                try
                {
                    Log.Debug(Constants.LOG_TAG, "Start sending report by " + s.GetType().Name);
                    s.Send(data);
                    Log.Debug(Constants.LOG_TAG, "Report was successfully sent by " + s.GetType().Name);
                }
                catch (ReportSenderException e)
                {
                    Log.Error(Constants.LOG_TAG, Throwable.FromException(e), e.Message);
                }
                catch (Exception e)
                {
                    Log.Error(Constants.LOG_TAG, Throwable.FromException(e),
                              "Unhandled error when sending report with " +
                              s.GetType().FullName);
                }
            });
            Log.Debug(Constants.LOG_TAG, "Report was builded and sent");
        }