Ignore:
Timestamp:
1/5/2010 2:48:26 AM (4 years ago)
Author:
lowjoel
Message:

Allow code to create crash dumps any time, not just when an unhandled exception is caught in the AppDomain?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/BlackBox/Eraser.Util/BlackBox.cs

    r1427 r1454  
    258258 
    259259        /// <summary> 
     260        /// Creates a new BlackBox report based on the exception provided. 
     261        /// </summary> 
     262        /// <param name="e">The exception which triggered this dump.</param> 
     263        public void CreateReport(Exception e) 
     264        { 
     265            if (e == null) 
     266                throw new ArgumentNullException("e"); 
     267 
     268            //Generate a unique identifier for this report. 
     269            string crashName = DateTime.Now.ToString("yyyyMMdd HHmmss.FFF"); 
     270            string currentCrashReport = Path.Combine(CrashReportsPath, crashName); 
     271            Directory.CreateDirectory(currentCrashReport); 
     272 
     273            //Write a memory dump to the folder 
     274            WriteMemoryDump(currentCrashReport, e); 
     275 
     276            //Then write a user-readable summary 
     277            WriteDebugLog(currentCrashReport, e); 
     278 
     279            //Take a screenshot 
     280            WriteScreenshot(currentCrashReport); 
     281        } 
     282 
     283        /// <summary> 
    260284        /// Enumerates the list of crash dumps waiting for upload. 
    261285        /// </summary> 
     
    286310        private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) 
    287311        { 
    288             //Generate a unique identifier for this report. 
    289             string crashName = DateTime.Now.ToString("yyyyMMdd HHmmss.FFF"); 
    290             string currentCrashReport = Path.Combine(CrashReportsPath, crashName); 
    291             Directory.CreateDirectory(currentCrashReport); 
    292  
    293             //Write a memory dump to the folder 
    294             Exception exception = (e.ExceptionObject as Exception); 
    295             WriteMemoryDump(currentCrashReport, exception); 
    296  
    297             //Then write a user-readable summary 
    298             WriteDebugLog(currentCrashReport, exception); 
    299  
    300             //Take a screenshot 
    301             WriteScreenshot(currentCrashReport); 
     312            CreateReport(e.ExceptionObject as Exception); 
    302313        } 
    303314 
Note: See TracChangeset for help on using the changeset viewer.