Exemple #1
0
        /// <summary>
        /// Gets the readable data location.
        /// </summary>
        /// <param name="element">
        /// The element.
        /// </param>
        /// <param name="qualifiedName">
        /// The qualified Name.
        /// </param>
        /// <returns>
        /// The <see cref="IReadableDataLocation"/>.
        /// </returns>
        public static IReadableDataLocation GetReadableDataLocation(this Message element, XmlQualifiedName qualifiedName)
        {
            if (element == null || element.IsEmpty)
            {
                throw new SdmxException("Missing message", SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.SemanticError));
            }

            var stream = new MemoryStream();

            using (var reader = element.GetReaderAtBodyContents())
            {
                if (!reader.ReadToDescendant(qualifiedName.Name, qualifiedName.Namespace))
                {
                    throw new SdmxException("Missing message", SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.SyntaxError));
                }

                using (XmlWriter writer = XmlWriter.Create(stream, new XmlWriterSettings {
                    Encoding = Encoding.UTF8
                }))
                {
                    writer.WriteNode(reader, true);
                    writer.Flush();
                }
            }

            return(new MemoryReadableLocation(stream.ToArray()));
        }
        /// <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>
 ///     Initializes static members of the <see cref="MessageFaultSoapv21Builder" /> class.
 /// </summary>
 static MessageFaultSoapv21Builder()
 {
     _sdmxErrorCodeIntenalError = SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.InternalServerError);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRetrieverException"/> class with a specified error message and error code
 /// </summary>
 /// <param name="errorMessage">
 /// The error message that explains the reason for the exception. 
 /// </param>
 /// <param name="errorCode">
 /// The error code
 /// </param>
 public DataRetrieverException(string errorMessage, SdmxErrorCode errorCode)
     : base(errorMessage, errorCode)
 {
     this._errorType = errorCode.ErrorString;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DataRetrieverException"/> class. Initializes with a specified error message and a reference to the inner exception that is the cause of this exception.
 /// </summary>
 /// <param name="nestedException">
 /// The exception that is the cause of the current exception. If the innerException parameter is not a null reference, the current exception is raised in a catch block that handles the inner exception. 
 /// </param>
 ///  /// <param name="errorCode">
 /// The error code 
 /// </param>
 /// <param name="message">
 /// The error message that explains the reason for the exception. 
 /// </param>
 public DataRetrieverException(Exception nestedException, SdmxErrorCode errorCode, string message)
     : base(nestedException, errorCode, message)
 {
     this._errorType = errorCode.ErrorString;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SdmxException"/> class. 
 /// Initializes a new instance of the <see cref="T:System.Exception"/> class with serialized data.
 /// </summary>
 /// <param name="info">
 /// The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown. 
 /// </param>
 /// <param name="context">
 /// The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination. 
 /// </param>
 /// <exception cref="T:System.ArgumentNullException">
 /// The <paramref name="info"/> parameter is null. 
 /// </exception>
 /// <exception cref="T:System.Runtime.Serialization.SerializationException">
 /// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0). 
 /// </exception>
 protected SdmxException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     this._errorCode = (SdmxErrorCode)info.GetValue("_errorCode", typeof(SdmxErrorCode));
     this._args = (object[])info.GetValue("_args", typeof(object[]));
     this._codeStr = info.GetString("_codeStr");
     this._code = (ExceptionCode)info.GetValue("_code", typeof(ExceptionCode));
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SdmxException"/> class. 
        /// Creates Exception from an error String and an Error code
        /// </summary>
        /// <param name="nestedException">
        /// The exception
        /// </param>
        /// <param name="errorCode">
        /// The error code
        /// </param>
        /// <param name="code">
        /// The exception code
        /// </param>
        /// <param name="args">
        /// The arguments
        /// </param>
        public SdmxException(Exception nestedException, SdmxErrorCode errorCode, ExceptionCode code, params object[] args)
            : base(nestedException != null ? nestedException.Message : errorCode != null ? errorCode.ErrorString : null, nestedException)
        {
            this._exception = nestedException;
            this._errorCode = errorCode;
            this._args = args;
            if (nestedException != null)
            {
                Console.Error.WriteLine(nestedException.StackTrace);
                if (errorCode == null)
                {
                    var exception = nestedException as SdmxException;
                    if (exception != null)
                    {
                        this._errorCode = exception.SdmxErrorCode;
                    }
                }
            }
            else
            {
                Console.Error.WriteLine(this);
            }
            if (code != null)
            {
                this._code = code;
                this._codeStr = code.Code;
            }

            _log.Error("Error ", this);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SdmxException"/> class. 
 /// Creates Exception from an error String and an Error code
 /// </summary>
 /// <param name="errorCode">
 /// The error code
 /// </param>
 /// <param name="code">
 /// The exception code
 /// </param>
 /// <param name="args">
 /// The arguments
 /// </param>
 public SdmxException(SdmxErrorCode errorCode, ExceptionCode code, params object[] args)
     : this(null, errorCode, code, args)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="SdmxException"/> class. 
        /// Creates Exception from an error String and an Error code
        /// </summary>
        /// <param name="nestedException">
        /// The exception
        /// </param>
        /// <param name="errorCode">
        /// The error code
        /// </param>
        /// <param name="message">
        /// the message
        /// </param>
        public SdmxException(Exception nestedException, SdmxErrorCode errorCode, string message)
            : base(message, nestedException)
        {
            this._exception = nestedException;
            if (errorCode != null)
            {
                this._errorCode = errorCode;
            }

            if (nestedException != null)
            {
                Console.Error.WriteLine(nestedException.StackTrace);
                if (errorCode == null)
                {

                    var exception = nestedException as SdmxException;
                    if (exception != null)
                    {
                        this._errorCode = exception.SdmxErrorCode;
                    }
                }
            }
            else
            {
                Console.Error.WriteLine(this);
            }

            _log.Error(message, this);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SdmxException"/> class. 
 /// Creates Exception from an error String and an Error code
 /// </summary>
 /// <param name="errorMessage">
 /// The error message
 /// </param>
 /// <param name="errorCode">
 /// The error code
 /// </param>
 public SdmxException(string errorMessage, SdmxErrorCode errorCode)
     : this(null, errorCode, errorMessage)
 {
 }
Exemple #11
0
 /// <summary>
 ///     Initializes static members of the <see cref="MessageFaultSoapv21Builder" /> class.
 /// </summary>
 static MessageFaultSoapv21Builder()
 {
     _sdmxErrorCodeIntenalError = SdmxErrorCode.GetFromEnum(SdmxErrorCodeEnumType.InternalServerError);
 }