Example #1
0
        private PluginExecutionResult ProcessActivity()
        {
            PluginRetryManager    retryManager = new PluginRetryManager(_executionData, TraceFactory.Logger.Debug);
            PluginExecutionResult finalResult  = retryManager.Run(() =>
            {
                PluginExecutionResult result = null;
                try
                {
                    result = _plugin.Execute(_executionData);
                }
                catch (WorkerHaltedException)
                {
                    // This exception must be explicitly re-thrown so it isn't eaten by the general catch
                    throw;
                }
                catch (ThreadAbortException ex)
                {
                    Thread.ResetAbort();

                    // Log the whole exception, including stack trace
                    TraceFactory.Logger.Error("Unhandled exception in plugin execution.", ex);
                    result = new PluginExecutionResult(PluginResult.Error, ex.ToString(), "Unhandled exception.");
                }
                catch (Exception ex)
                {
                    // Log the whole exception, including stack trace
                    TraceFactory.Logger.Error("Unhandled exception in plugin execution.", ex);
                    result = new PluginExecutionResult(PluginResult.Error, ex.ToString(), "Unhandled exception.");
                }
                return(result);
            });

            if (finalResult.RetryStatus == PluginRetryStatus.Halt)
            {
                throw new WorkerHaltedException("Retry limit reached");
            }
            return(finalResult);
        }