Пример #1
0
        private void WebServiceErrorProcessing(WebServiceException exception, string funcName)
        {
            string exceptionString = String.Format("{0}: {1}():", GetTypeNamespace(), funcName);

            exceptionString += String.Format("\nStatusCode = {0}", exception.StatusCode);
            exceptionString += String.Format("\nStatusDescription = {0}", exception.StatusDescription);
            exceptionString += String.Format("\nErrorCode = {0}", exception.ErrorCode);
            exceptionString += String.Format("\nErrorMessage = {0}", exception.ErrorMessage);
            exceptionString += String.Format("\nStackTrace = {0}", exception.StackTrace);
            exceptionString += String.Format("\nResponseDto = {0}", exception.ResponseDto);
            exceptionString += String.Format("\nResponseStatus = {0}", exception.ResponseStatus);
            exceptionString += String.Format("\nGetFieldErrors() = {0}", exception.GetFieldErrors());

            Debug.WriteLine(exceptionString);
        }
        internal static ComposerException Create(WebServiceException source)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            var errors = source.GetFieldErrors().Select(error => new ErrorViewModel
            {
                ErrorCode    = error.ErrorCode,
                ErrorMessage = error.Message
            }).ToList();

            if (errors.All(e => e.ErrorCode != source.ErrorCode))
            {
                errors.Add(new ErrorViewModel
                {
                    ErrorCode    = source.ErrorCode,
                    ErrorMessage = source.ErrorMessage
                });
            }

            return(new ComposerException(errors));
        }