Ejemplo n.º 1
0
 private void ProcessSchemaValidationError(CodedStatusMessageType errorMessage, SchemaValidationException e)
 {
     foreach (string error in e.GetValidationErrors())
     {
         TextType text = new TextType();
         errorMessage.Text.Add(text);
         text.TypedValue = error;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Build error response.
        /// </summary>
        /// <param name="errorCode">
        /// The error code.
        /// </param>
        /// <returns>
        /// The <see cref="Error"/>.
        /// </returns>
        public Error BuildErrorResponse(SdmxErrorCode errorCode)
        {
            var errorDoc = new Error();
            ErrorType error = errorDoc.Content;

            // FUNC Standard error codes
            var errorMessage = new CodedStatusMessageType();
            error.ErrorMessage.Add(errorMessage);
            errorMessage.code = errorCode.ClientErrorCode.ToString(CultureInfo.InvariantCulture);
            var text = new TextType();
            errorMessage.Text.Add(text);
            text.TypedValue = errorCode.ErrorString;
            return errorDoc;
        }
        /// <summary>
        /// Build error response.
        /// </summary>
        /// <param name="exception">
        /// The exception.
        /// </param>
        /// <returns>
        /// The <see cref="Error"/>.
        /// </returns>
        public Error BuildErrorResponse(Exception exception)
        {
            var errorDoc = new Error();
            ErrorType error = errorDoc.Content;

            // FUNC Standard error codes
            var errorMessage = new CodedStatusMessageType();
            error.ErrorMessage.Add(errorMessage);
            errorMessage.code = "1000";
            var text = new TextType();
            errorMessage.Text.Add(text);
            var uncheckedException = exception as SdmxException;
            text.TypedValue = uncheckedException != null ? uncheckedException.FullMessage : exception.Message;

            return errorDoc;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Build error response.
        /// </summary>
        /// <param name="exception">
        /// The exception.
        /// </param>
        /// <param name="exceptionCode">
        /// The exception code.
        /// </param>
        /// <returns>
        /// The <see cref="XTypedElement"/>.
        /// </returns>
        public virtual XTypedElement BuildErrorResponse(Exception exception, string exceptionCode)
        {
            var errorDocument = new Error();

            var errorMessage = new CodedStatusMessageType();
            errorDocument.ErrorMessage.Add(errorMessage);

            errorMessage.code = exceptionCode;
            while (exception != null)
            {
                var text = new TextType();
                errorMessage.Text.Add(text);
                if (string.IsNullOrEmpty(exception.Message))
                {
                    if (exception.InnerException != null)
                    {
                        text.TypedValue = exception.InnerException.Message;
                    }
                }
                else
                {
                    text.TypedValue = exception.Message;
                }

                if (exception.GetType() == typeof(SchemaValidationException))
                {
                    ProcessSchemaValidationError(errorMessage, (SchemaValidationException)exception);
                }
                else
                {
                    ProcessThrowable(errorMessage, exception);
                }

                exception = exception.InnerException;
            }

            return errorDocument;
        }
Ejemplo n.º 5
0
        private void ProcessThrowable(CodedStatusMessageType errorMessage, Exception th)
        {
            TextType text = new TextType();
            errorMessage.Text.Add(text);

            if (th.Message == null)
            {
                if (th.GetBaseException() != null)
                {
                    text.TypedValue = th.GetBaseException().Message;
                }
                else
                {
                    if (th.GetType() == typeof(NullReferenceException))
                    {
                        text.TypedValue = "Null Reference Exception";
                    }
                    else
                    {
                        text.TypedValue = "No Error Message Provided";
                    }
                }
            }
            else
            {
                text.TypedValue = th.Message;
            }
        }