Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:XmppException"/> class with the given class
 /// </summary>
 /// <param name="message">The XMPP Stream error.</param>
 public XmppException(StreamError error)
     : base(GetStreamErrorMessage(error))
 {
 }
Ejemplo n.º 2
0
        private static string GetStreamErrorMessage(StreamError message)
        {
            StringBuilder exceptionMessage = new StringBuilder();

            if (message.BadFormat != null)
            {
                exceptionMessage.Append("bad-format");
            }
            else if (message.BadNamespacePrefix != null)
            {
                exceptionMessage.Append("bad-namespace-prefix");
            }
            else if (message.Conflict != null)
            {
                exceptionMessage.Append("conflict");
            }
            else if (message.ConnectionTimeout != null)
            {
                exceptionMessage.Append("connection-timeout");
            }
            else if (message.HostGone != null)
            {
                exceptionMessage.Append("host-gone");
            }
            else if (message.HostUnknown != null)
            {
                exceptionMessage.Append("host-unknown");
            }
            else if (message.ImproperAddressing != null)
            {
                exceptionMessage.Append("improper-addressing");
            }
            else if (message.InternalServerError != null)
            {
                exceptionMessage.Append("internal-server-error");
            }
            else if (message.InvalidFrom != null)
            {
                exceptionMessage.Append("invalid-from");
            }
            else if (message.InvalidID != null)
            {
                exceptionMessage.Append("invalid-id");
            }
            else if (message.InvalidNamespace != null)
            {
                exceptionMessage.Append("invalid-namespace");
            }
            else if (message.InvalidXml != null)
            {
                exceptionMessage.Append("invalid-xml");
            }
            else if (message.NotAuthorized != null)
            {
                exceptionMessage.Append("not-authorized");
            }
            else if (message.PolicyViolation != null)
            {
                exceptionMessage.Append("policy-violation");
            }
            else if (message.RemoteConnectionFailed != null)
            {
                exceptionMessage.Append("remote-connection-failed");
            }
            else if (message.ResourceConstraint != null)
            {
                exceptionMessage.Append("resource-constraint");
            }
            else if (message.RestrictedXml != null)
            {
                exceptionMessage.Append("restricted-xml");
            }
            else if (message.SeeOtherHost != null)
            {
                exceptionMessage.Append("see-other-host");
            }
            else if (message.SystemShutdown != null)
            {
                exceptionMessage.Append("system-shutdown");
            }
            else if (message.UndefinedCondition != null)
            {
                exceptionMessage.Append("undefined-condition");
            }
            else if (message.UnsupportedEncoding != null)
            {
                exceptionMessage.Append("unsupported-encoding");
            }
            else if (message.UnsupportedStanzaType != null)
            {
                exceptionMessage.Append("unsupported-stanza-type");
            }
            else if (message.UnsupportedVersion != null)
            {
                exceptionMessage.Append("unsupported-version");
            }
            else if (message.XmlNotWellFormed != null)
            {
                exceptionMessage.Append("xml-not-well-formed");
            }

            if (message.Text != null && message.Text.Value != null)
            {
                exceptionMessage.AppendFormat("{0}{1}", Environment.NewLine, message.Text.Value);
            }

            return exceptionMessage.ToString();
        }