Exemple #1
0
        /// <summary>
        /// Unwraps the specified <paramref name="wrappedException"/> and returns the originating exception.
        /// </summary>
        /// <param name="wrappedException">The wrapped exception to unwrap.</param>
        /// <returns>The originating exception from within <see cref="MethodWrappedException"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="wrappedException"/> is null.
        /// </exception>
        public static Exception Unwrap(MethodWrappedException wrappedException)
        {
            Validator.ThrowIfNull(wrappedException, nameof(wrappedException));
            var original = wrappedException.InnerException;

            if (!original.Data.Contains(ThrowingMethod))
            {
                original.Data.Add(ThrowingMethod, wrappedException.ToString());
            }
            return(original);
        }
 /// <summary>
 /// Unwraps the specified <paramref name="wrappedException"/>.
 /// </summary>
 /// <param name="wrappedException">The wrapped exception to unwrap.</param>
 /// <returns>The originating exception from within <see cref="MethodWrappedException"/>.</returns>
 public static Exception Unwrap(this MethodWrappedException wrappedException)
 {
     return(ExceptionUtility.Unwrap(wrappedException));
 }