/// <summary>
        /// Gets message for the specified service exception.
        /// </summary>
        /// <param name="message">The text to prefix generated exception message
        /// with.</param>
        /// <param name="serviceException">The exception to generate message for.</param>
        /// <returns>Text describing the specified service exception.</returns>
        private static string _GetServiceExceptionMessage(string message,
                                                          RestException serviceException)
        {
            Debug.Assert(message != null);
            Debug.Assert(serviceException != null);

            string serviceMsg = serviceException.Message;

            if (!string.IsNullOrEmpty(serviceMsg))
            {
                return(string.Format(Properties.Messages.Error_ArcgisRestError,
                                     message,
                                     serviceMsg));
            }

            var errorCode = string.Format(CultureInfo.InvariantCulture,
                                          Properties.Resources.ArcGisRestErrorCodeFormat,
                                          serviceException.ErrorCode);

            var errorMessage = string.Format(Properties.Messages.Error_ArcgisRestUnspecifiedError,
                                             message,
                                             errorCode);

            return(errorMessage);
        }
        /// <summary>
        /// Creates RouteException object by REST service exception.
        /// </summary>
        /// <param name="message">Message text.</param>
        /// <param name="serviceEx">Service exception to conversion.</param>
        public static RouteException ConvertServiceException(string message, RestException serviceEx)
        {
            Debug.Assert(!string.IsNullOrEmpty(message));
            Debug.Assert(serviceEx != null);

            var errorMessage = _GetServiceExceptionMessage(message, serviceEx);
            return new RouteException(errorMessage, serviceEx); // exception
        }
        /// <summary>
        /// Creates RouteException object by REST service exception.
        /// </summary>
        /// <param name="message">Message text.</param>
        /// <param name="serviceEx">Service exception to conversion.</param>
        public static RouteException ConvertServiceException(string message, RestException serviceEx)
        {
            Debug.Assert(!string.IsNullOrEmpty(message));
            Debug.Assert(serviceEx != null);

            var errorMessage = _GetServiceExceptionMessage(message, serviceEx);

            return(new RouteException(errorMessage, serviceEx)); // exception
        }
Beispiel #4
0
        private static void _LogServiceError(RestException ex)
        {
            var error = new GPError();

            error.Message = ex.Message;
            error.Code    = ex.ErrorCode;
            error.Details = ex.Details;

            Logger.Error(_BuildFaultResponseLog(error));
        }
        /// <summary>
        /// Creates RestException object.
        /// </summary>
        public static RestException CreateRestException(IFaultInfo faultInfo)
        {
            Debug.Assert(faultInfo != null);
            Debug.Assert(faultInfo.IsFault);

            RestException ex = null;

            GPError error = faultInfo.FaultInfo;

            if (error != null)
            {
                ex = new RestException(error.Message, error.Code,
                                       error.Details);
            }
            else
            {
                ex = new RestException(
                    Properties.Messages.Error_InvalidArcgisRestResponse);
            }

            return(ex);
        }
        /// <summary>
        /// Gets message for the specified service exception.
        /// </summary>
        /// <param name="message">The text to prefix generated exception message
        /// with.</param>
        /// <param name="serviceException">The exception to generate message for.</param>
        /// <returns>Text describing the specified service exception.</returns>
        private static string _GetServiceExceptionMessage(string message,
                                                          RestException serviceException)
        {
            Debug.Assert(message != null);
            Debug.Assert(serviceException != null);

            string serviceMsg = serviceException.Message;
            if (!string.IsNullOrEmpty(serviceMsg))
            {
                return string.Format(Properties.Messages.Error_ArcgisRestError,
                                     message,
                                     serviceMsg);
            }

            var errorCode = string.Format(CultureInfo.InvariantCulture,
                                          Properties.Resources.ArcGisRestErrorCodeFormat,
                                          serviceException.ErrorCode);

            var errorMessage = string.Format(Properties.Messages.Error_ArcgisRestUnspecifiedError,
                                             message,
                                             errorCode);
            return errorMessage;
        }