// 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); }
public virtual Exception ToException(IInteractionFault fault) { fault.EnsureNotNull(nameof(fault)); // return (fault .TreeNode() .Transform <IInteractionFault, Exception>( childrenSelector: locFault => locFault.InnerFaults, transform: CreateException)); }
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(); }
public InteractionFaultException(string message, IInteractionFault fault, IEnumerable <Exception> innerExceptions) : base(message, innerExceptions.SkipNull().FirstOrDefault()) { _fault = fault; _innerExceptions = innerExceptions.SkipNull().ToArray().AsReadOnlyCollection(); }
public InteractionFaultException(string message, IInteractionFault fault, Exception innerException) : this(message, fault, innerException.Sequence()) { }
public InteractionInnerFault(IInteractionFault fault) { fault.EnsureNotNull(nameof(fault)); // Fault = fault.Fluent().ConvertNullCond(converter: locFault => new InteractionFault(locFault)); }