예제 #1
0
 private async void ReportException(Exception exception)
 {
     try
     {
         await ReportingService.ReportErrorAsync(exception, this.webJobIdentifier, null);
     }
     catch (Exception t)
     {
         this.Log(string.Format("Error: Failed to report error: " + t));
     }
 }
        private static async Task ReportSomeErrorsAsync()
        {
            // Error #1: Manual 'Exception'.
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Press any key to record some manual 'exceptions'...");
            Console.ReadKey();

            try
            {
                throw new Exception();
            }
            catch (Exception exception)
            {
                await _errorReportingService.ReportExceptionAsync(exception);
            }

            try
            {
                throw new Exception("Exception");
            }
            catch (Exception exception)
            {
                await _errorReportingService.ReportExceptionAsync(exception);
            }

            try
            {
                throw new Exception("Exception with inner exception", new Exception("Inner exception"));
            }
            catch (Exception exception)
            {
                await _errorReportingService.ReportExceptionAsync(exception);
            }

            // Error #2: Manual 'Error'.
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Press any key to record a manual 'error'...");
            Console.ReadKey();
            await _errorReportingService.ReportErrorAsync("This is a manual error");

            // Error #3: Application crash.
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Okay, now we're going to actually crash...to see if the tool has some magic 'hooks' to record on it. Press any key, and then hold onto your butts!!");
            Console.ReadKey();
            throw new Exception("This application has crashed! Arrrgghhhhh!");
        }
예제 #3
0
 public void ReportExceptionAsync(Exception exception)
 {
     ReportingService.ReportErrorAsync(exception, this.webJobIdentifier, null);
 }