Example #1
0
        public static void ThrowIfError(this Iq source)
        {
            // do not throw error if the IQ is good
            if (source == null || source.Type != IqType.Error)
            {
                return;
            }

            // throw unspecified error if no error element exists
            var errorElement = source.Data["error"];

            if (errorElement == null)
            {
                throw new XmppException("An unspecified error occured");
            }

            // parse error
            XmppError error;

            try
            {
                error = new XmppError(errorElement);
            }
            catch
            {
                throw new XmppException("An unspecified error occured");
            }

            // throw error (using error text or error condition)
            if (!string.IsNullOrEmpty(error.Text))
            {
                throw new XmppErrorException(error, error.Text);
            }

            throw new XmppErrorException(error, error.Condition.ToString());
        }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the XmppErrorException class with its message
 /// string set to <paramref name="message"/> and a reference to the inner exception that
 /// is the cause of this exception.
 /// </summary>
 /// <param name="error">The XMPP error that is the reason for the exception.</param>
 /// <param name="message">A description of the error. The content of message is intended
 /// to be understood by humans.</param>
 /// <param name="inner">The exception that is the cause of the current exception.</param>
 /// <exception cref="ArgumentNullException">The error parameter is null.</exception>
 public XmppErrorException(XmppError error, string message, Exception inner)
     : base(message, inner)
 {
     error.ThrowIfNull("error");
     Error = error;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the XmppErrorException class with the specified
 /// serialization and context information.
 /// </summary>
 /// <param name="error">The XMPP error that is the reason for the exception.</param>
 /// <param name="info">An object that holds the serialized object data about the exception
 /// being thrown. </param>
 /// <param name="context">An object that contains contextual information about the source
 /// or destination. </param>
 /// <exception cref="ArgumentNullException">The error parameter is null.</exception>
 protected XmppErrorException(XmppError error, SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     error.ThrowIfNull("error");
     Error = error;
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the XmppErrorException class
 /// </summary>
 /// <param name="error">The XMPP error that is the reason for the exception.</param>
 /// <exception cref="ArgumentNullException">The error parameter is null.</exception>
 public XmppErrorException(XmppError error)
     : base()
 {
     error.ThrowIfNull("error");
     Error = error;
 }