ExceptionList.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //using System;
  2. //using System.Collections.Generic;
  3. //using System.Diagnostics;
  4. //using System.Runtime.ExceptionServices;
  5. //using System.Text;
  6. //namespace OpenVIII
  7. //{
  8. // public sealed class ExceptionList : IDisposable
  9. // {
  10. // private readonly List<Exception> _exceptions = new List<Exception>();
  11. // public void Add(Exception ex)
  12. // {
  13. // Debug.WriteLine(ex); // doesn't seem like this list is used correctly. so adding this writeline to atleast spit out the error.
  14. // _exceptions.Add(ex);
  15. // }
  16. // public void Clear()
  17. // {
  18. // _exceptions.Clear();
  19. // }
  20. // public void Dispose()
  21. // {
  22. // switch (_exceptions.Count)
  23. // {
  24. // case 0:
  25. // {
  26. // return;
  27. // }
  28. // case 1:
  29. // {
  30. // ExceptionDispatchInfo.Capture(_exceptions[0]).Throw();
  31. // return;
  32. // }
  33. // default:
  34. // {
  35. // StringBuilder sb = new StringBuilder();
  36. // foreach (var ex in _exceptions)
  37. // sb.AppendLine(ex.Message);
  38. // //https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1065-do-not-raise-exceptions-in-unexpected-locations?view=vs-2015&redirectedfrom=MSDN
  39. // // cannot raise exceptions in dispose.
  40. // //throw new AggregateException(sb.ToString(), _exceptions);
  41. // return;
  42. // }
  43. // }
  44. // }
  45. // }
  46. //}