ExceptionExtensions.cs 628 B

123456789101112131415161718192021
  1. using System;
  2. using System.Runtime.ExceptionServices;
  3. namespace Abp.Extensions
  4. {
  5. /// <summary>
  6. /// Extension methods for <see cref="Exception"/> class.
  7. /// </summary>
  8. public static class ExceptionExtensions
  9. {
  10. /// <summary>
  11. /// Uses <see cref="ExceptionDispatchInfo.Capture"/> method to re-throws exception
  12. /// while preserving stack trace.
  13. /// </summary>
  14. /// <param name="exception">Exception to be re-thrown</param>
  15. public static void ReThrow(this Exception exception)
  16. {
  17. ExceptionDispatchInfo.Capture(exception).Throw();
  18. }
  19. }
  20. }