Example #1
0
        /// <summary>
        /// Creates fault exception using supplied parameters.
        /// </summary>
        /// <typeparam name="T">The type of fault.</typeparam>
        /// <param name="ex">The exception.</param>
        /// <param name="source">The error source.</param>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="isFatal">The value indicating whether the error is fatal.</param>
        /// <returns>The type of fault.</returns>
        public static T CreateFaultFromException <T>(Exception ex, string source, string message, bool isFatal) where T : CoreFault, new()
        {
            T fault = new T();

            fault.Source = source;

            if (string.IsNullOrEmpty(message))
            {
                fault.Description = ex.Message;
            }
            else
            {
                fault.Description = message;
            }

            fault.ErrorCode = ex.GetHashCode();

            fault.IsFatal = isFatal;

            fault.Reason = new FaultReason(fault.Description);

            fault.Exception = ExceptionStub.CreateExceptionStub(ex);
            return(fault);
        }