Esempio n. 1
0
        static void Case1(IDictionary <string, string> settings)
        {
            var config   = AirbrakeConfig.Load(settings);
            var notifier = new AirbrakeNotifier(config);

            try
            {
                throw new Exception("Case 1. Exception 1. Time: " + DateTime.Now.ToString("hh.mm.ss.ffffff"));
            }
            catch (Exception ex)
            {
                notifier.Notify(ex);
            }

            try
            {
                throw new Exception("Case 1. Exception 2. Time: " + DateTime.Now.ToString("hh.mm.ss.ffffff"));
            }
            catch (Exception ex)
            {
                notifier.Notify(ex);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Uses NotifyAsync method that allows to handle explicitly what to do with response.
        /// In our case response are output to console.
        /// </summary>
        static void Case2(IDictionary <string, string> settings)
        {
            var config   = AirbrakeConfig.Load(settings);
            var notifier = new AirbrakeNotifier(config);

            notifier.NotifyCompleted += (sender, eventArgs) =>
            {
                if (eventArgs.Error != null)
                {
                    Console.WriteLine(eventArgs.Error.Message);
                }
                else if (eventArgs.Result != null)
                {
                    var response = eventArgs.Result;
                    Console.WriteLine("Status: {0}, Id: {1}, Url: {2}", response.Status, response.Id, response.Url);
                }
            };

            try
            {
                throw new Exception("Case 2. Exception 1. Time: " + DateTime.Now.ToString("hh.mm.ss.ffffff"));
            }
            catch (Exception ex)
            {
                notifier.NotifyAsync(ex);
            }

            try
            {
                throw new Exception("Case 2. Exception 2. Time: " + DateTime.Now.ToString("hh.mm.ss.ffffff"));
            }
            catch (Exception ex)
            {
                notifier.NotifyAsync(ex);
            }
        }