コード例 #1
0
        // TODO: Put strings into the resources.
        //
        protected virtual Exception CreateException(IInteractionFault fault, IEnumerable <Exception> innerExceptions)
        {
            fault.EnsureNotNull(nameof(fault));
            //
            var faultCode        = fault.Code;
            var exceptionMessage = string.IsNullOrEmpty(fault.Message) ? null : fault.Message;

            exceptionMessage =
                $"{Environment.NewLine}--- Начало сведений об ошибке удалённой стороны ---"
                + $"{Environment.NewLine}\tКод:{faultCode.FmtStr().GNLI2()}"
                + (exceptionMessage == null ? string.Empty : $"{Environment.NewLine}\tСообщение:{exceptionMessage.FmtStr().GNLI2()}")
                + (fault.TypeName == null ? string.Empty : $"{Environment.NewLine}\tИмя типа:{fault.TypeName.FmtStr().GNLI2()}")
                + (fault.StackTrace == null ? string.Empty : $"{Environment.NewLine}\tТрассировка стека:{fault.StackTrace.FmtStr().GNLI2()}")
                + $"{Environment.NewLine}--- Конец сведений об ошибке удалённой стороны ---";
            var exception =
                new InteractionFaultException(
                    message: exceptionMessage,
                    fault: fault,
                    innerExceptions: innerExceptions.EmptyIfNull().SkipNull());

            if (faultCode != null)
            {
                exception
                .SetErrorCode(
                    code:
                    new ErrorCode(
                        identifier: faultCode.Identifier,
                        description: faultCode.Description,
                        severityLevel: faultCode.SeverityLevel));
            }
            return(exception);
        }
コード例 #2
0
 public virtual Exception ToException(IInteractionFault fault)
 {
     fault.EnsureNotNull(nameof(fault));
     //
     return
         (fault
          .TreeNode()
          .Transform <IInteractionFault, Exception>(
              childrenSelector: locFault => locFault.InnerFaults,
              transform: CreateException));
 }
コード例 #3
0
 public InteractionFault(IInteractionFault other)
 {
     other.EnsureNotNull(nameof(other));
     //
     Code =
         other
         .Code
         .Fluent().ConvertNullCond(locCode => new InteractionFaultCode(locCode));
     Message     = other.Message;
     TypeName    = other.TypeName;
     StackTrace  = other.StackTrace;
     InnerFaults =
         other
         .InnerFaults
         .EmptyIfNull()
         .Select(i => i == null ? new InteractionInnerFault() : new InteractionInnerFault(i))
         .ToArray();
 }
コード例 #4
0
 public InteractionFaultException(string message, IInteractionFault fault, IEnumerable <Exception> innerExceptions)
     : base(message, innerExceptions.SkipNull().FirstOrDefault())
 {
     _fault           = fault;
     _innerExceptions = innerExceptions.SkipNull().ToArray().AsReadOnlyCollection();
 }
コード例 #5
0
 public InteractionFaultException(string message, IInteractionFault fault, Exception innerException)
     : this(message, fault, innerException.Sequence())
 {
 }
コード例 #6
0
 public InteractionInnerFault(IInteractionFault fault)
 {
     fault.EnsureNotNull(nameof(fault));
     //
     Fault = fault.Fluent().ConvertNullCond(converter: locFault => new InteractionFault(locFault));
 }