winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

ExceptionExtensions.cs (1039B)


      1 // -----------------------------------------------------------------------------
      2 // <copyright file="ExceptionExtensions.cs" company="Microsoft Corporation">
      3 //     Copyright (c) Microsoft Corporation. Licensed under the MIT License.
      4 // </copyright>
      5 // -----------------------------------------------------------------------------
      6 
      7 namespace Microsoft.Management.Configuration.Processor.Extensions
      8 {
      9     using System;
     10 
     11     /// <summary>
     12     /// Extension method for Exception.
     13     /// </summary>
     14     internal static class ExceptionExtensions
     15     {
     16         /// <summary>
     17         /// Gets the most inner exception.
     18         /// </summary>
     19         /// <param name="e">Exception.</param>
     20         /// <returns>Most inner exception.</returns>
     21         public static Exception GetMostInnerException(this Exception e)
     22         {
     23             Exception ex = e;
     24             while (ex.InnerException != null)
     25             {
     26                 ex = ex.InnerException;
     27             }
     28 
     29             return ex;
     30         }
     31     }
     32 }