Exemplo n.º 1
0
        /// <summary>
        /// Extracts the fault (<see cref="FaultException{Fault}.Detail"/>) from the exception and converts it to the corresponding exception.
        /// </summary>
        /// <param name="exception">The exception corresponding to the fault.</param>
        /// <returns>The new exception or the original (this) if not successful.</returns>
        public static Exception ToException(
            this FaultException exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException(nameof(exception));
            }

            var fault = exception.ToFault();

            if (fault == null)
            {
                return(exception);
            }
            else
            {
                return(fault.ToException());
            }
        }