aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/BadRequestIqErrorException.java17
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/InternalServerErrorException.java17
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/IqPacketErrorException.java20
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredContentException.java26
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredElementException.java26
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/ServiceUnavailableException.java17
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UndefinedConditionException.java17
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UnexpectedIqPacketTypeException.java25
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/XmppException.java56
9 files changed, 221 insertions, 0 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/BadRequestIqErrorException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/BadRequestIqErrorException.java
new file mode 100644
index 00000000..120ef495
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/BadRequestIqErrorException.java
@@ -0,0 +1,17 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ * Created by steckbrief on 22.08.2016.
+ */
+public class BadRequestIqErrorException extends IqPacketErrorException {
+ public BadRequestIqErrorException(Element context, String errorMessage) {
+ super(context, errorMessage);
+ }
+
+ @Override
+ public String getMessage() {
+ return "Bad Request: " + super.getMessage();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/InternalServerErrorException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/InternalServerErrorException.java
new file mode 100644
index 00000000..1a1cded2
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/InternalServerErrorException.java
@@ -0,0 +1,17 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ * Created by steckbrief on 22.08.2016.
+ */
+public class InternalServerErrorException extends IqPacketErrorException {
+ public InternalServerErrorException(Element packet, String errorText) {
+ super(packet, errorText);
+ }
+
+ @Override
+ public String getMessage() {
+ return "Internal Server Error: " + super.getMessage();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/IqPacketErrorException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/IqPacketErrorException.java
new file mode 100644
index 00000000..65e02688
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/IqPacketErrorException.java
@@ -0,0 +1,20 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ * Created by steckbrief on 22.08.2016.
+ */
+public class IqPacketErrorException extends XmppException {
+ private final String iqErrorText;
+
+ public IqPacketErrorException(Element context, String errorMessage) {
+ super(context);
+ this.iqErrorText = errorMessage;
+ }
+
+ @Override
+ public String getMessage() {
+ return this.iqErrorText + " in context: " + this.getContext();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredContentException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredContentException.java
new file mode 100644
index 00000000..060bb618
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredContentException.java
@@ -0,0 +1,26 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ *
+ */
+public class MissingRequiredContentException extends XmppException {
+ private String elementName;
+ private String namespace;
+
+ public MissingRequiredContentException(String elementName, Element context) {
+ super(context);
+ this.elementName = elementName;
+ }
+
+ public MissingRequiredContentException(String elementName, String namespace, Element context) {
+ this(elementName, context);
+ this.namespace = namespace;
+ }
+
+ @Override
+ public String getMessage() {
+ return "Missing required element content " + ((namespace != null) ? namespace + ":" : "") + elementName + " in context " + getContext();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredElementException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredElementException.java
new file mode 100644
index 00000000..de24262f
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/MissingRequiredElementException.java
@@ -0,0 +1,26 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ *
+ */
+public class MissingRequiredElementException extends XmppException {
+ private String elementName;
+ private String namespace;
+
+ public MissingRequiredElementException(String elementName, Element context) {
+ super(context);
+ this.elementName = elementName;
+ }
+
+ public MissingRequiredElementException(String elementName, String namespace, Element context) {
+ this(elementName, context);
+ this.namespace = namespace;
+ }
+
+ @Override
+ public String getMessage() {
+ return "Missing required element " + ((namespace != null) ? namespace + ":" : "") + elementName + " in context " + getContext();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/ServiceUnavailableException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/ServiceUnavailableException.java
new file mode 100644
index 00000000..88d5389b
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/ServiceUnavailableException.java
@@ -0,0 +1,17 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ * Created by steckbrief on 22.08.2016.
+ */
+public class ServiceUnavailableException extends IqPacketErrorException {
+ public ServiceUnavailableException(Element context, String errorMessage) {
+ super(context, errorMessage);
+ }
+
+ @Override
+ public String getMessage() {
+ return "Service unavailable: " + super.getMessage();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UndefinedConditionException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UndefinedConditionException.java
new file mode 100644
index 00000000..de821873
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UndefinedConditionException.java
@@ -0,0 +1,17 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ * Created by steckbrief on 22.08.2016.
+ */
+public class UndefinedConditionException extends IqPacketErrorException {
+ public UndefinedConditionException(Element packet, String errorText) {
+ super(packet, errorText);
+ }
+
+ @Override
+ public String getMessage() {
+ return "Undefined Condition: " + super.getMessage();
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UnexpectedIqPacketTypeException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UnexpectedIqPacketTypeException.java
new file mode 100644
index 00000000..82f229e8
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/UnexpectedIqPacketTypeException.java
@@ -0,0 +1,25 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import java.util.Arrays;
+
+import eu.siacs.conversations.xml.Element;
+import eu.siacs.conversations.xmpp.stanzas.IqPacket;
+
+/**
+ *
+ */
+public class UnexpectedIqPacketTypeException extends XmppException {
+ private final IqPacket.TYPE current;
+ private final IqPacket.TYPE[] expected;
+
+ public UnexpectedIqPacketTypeException(Element context, IqPacket.TYPE current, IqPacket.TYPE... expected) {
+ super(context);
+ this.expected = expected;
+ this.current = current;
+ }
+
+ @Override
+ public String getMessage() {
+ return "Unexpected IQ packet type '" + this.current + "' retrieved. One of " + Arrays.toString(expected) + " was expected.";
+ }
+}
diff --git a/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/XmppException.java b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/XmppException.java
new file mode 100644
index 00000000..b8c6c89d
--- /dev/null
+++ b/src/main/java/de/thedevstack/conversationsplus/xmpp/exceptions/XmppException.java
@@ -0,0 +1,56 @@
+package de.thedevstack.conversationsplus.xmpp.exceptions;
+
+import eu.siacs.conversations.xml.Element;
+
+/**
+ *
+ */
+public class XmppException extends Exception {
+ private Element context;
+ /**
+ * Constructs a new {@code Exception} that includes the current stack trace.
+ */
+ public XmppException() {
+ }
+
+ /**
+ * Constructs a new {@code Exception} that includes the current stack trace.
+ */
+ public XmppException(Element context) {
+ this.context = context;
+ }
+
+ /**
+ * Constructs a new {@code Exception} with the current stack trace and the
+ * specified cause.
+ *
+ * @param throwable the cause of this exception.
+ */
+ public XmppException(Throwable throwable) {
+ super(throwable);
+ }
+
+ /**
+ * Constructs a new {@code Exception} with the current stack trace and the
+ * specified cause.
+ *
+ * @param throwable the cause of this exception.
+ */
+ public XmppException(Element context, Throwable throwable) {
+ super(throwable);
+ this.context = context;
+ }
+
+ @Override
+ public String getMessage() {
+ if (null != context) {
+ return "Error in XMPP Element. XML element is: " + this.context.toString();
+ } else {
+ return super.getMessage();
+ }
+ }
+
+ public Element getContext() {
+ return context;
+ }
+}