]> nmode's Git Repositories - signal-cli/commitdiff
Fix exceptions to work over dbus
authorAsamK <asamk@gmx.de>
Wed, 30 Dec 2015 16:39:07 +0000 (17:39 +0100)
committerAsamK <asamk@gmx.de>
Wed, 30 Dec 2015 16:39:07 +0000 (17:39 +0100)
src/main/java/org/asamk/textsecure/AttachmentInvalidException.java
src/main/java/org/asamk/textsecure/GroupNotFoundException.java
src/main/java/org/asamk/textsecure/Main.java

index bf2272695b04f7cbb67e7b12b71bc6d53bc5cbc2..5afa67e37356658e583f61e4e5f1c2a379a188dd 100644 (file)
@@ -1,14 +1,13 @@
 package org.asamk.textsecure;
 
 package org.asamk.textsecure;
 
-public class AttachmentInvalidException extends Exception {
-    private final String attachment;
+import org.freedesktop.dbus.exceptions.DBusExecutionException;
 
 
-    public AttachmentInvalidException(String attachment, Exception e) {
-        super(e);
-        this.attachment = attachment;
+public class AttachmentInvalidException extends DBusExecutionException {
+    public AttachmentInvalidException(String message) {
+        super(message);
     }
 
     }
 
-    public String getAttachment() {
-        return attachment;
+    public AttachmentInvalidException(String attachment, Exception e) {
+        super(attachment + ": " + e.getMessage());
     }
 }
     }
 }
index 57f4cef8fe2bbce244e8cdc1330fc8cdcae987f3..6c4cf5b13462d5d0714f8032dc4029e931841751 100644 (file)
@@ -1,14 +1,14 @@
 package org.asamk.textsecure;
 
 package org.asamk.textsecure;
 
-public class GroupNotFoundException extends Exception {
-    private final byte[] groupId;
+import org.freedesktop.dbus.exceptions.DBusExecutionException;
 
 
-    public GroupNotFoundException(byte[] groupId) {
-        super();
-        this.groupId = groupId;
+public class GroupNotFoundException extends DBusExecutionException {
+
+    public GroupNotFoundException(String message) {
+        super(message);
     }
 
     }
 
-    public byte[] getGroupId() {
-        return groupId;
+    public GroupNotFoundException(byte[] groupId) {
+        super("Group not found: " + Base64.encodeBytes(groupId));
     }
 }
     }
 }
index 2f2825a8cdec77beb48f7539cce80913950da04c..7213a945211398409cb3607933764c3cc4a5c6c0 100644 (file)
@@ -180,7 +180,7 @@ public class Main {
                         } catch (GroupNotFoundException e) {
                             handleGroupNotFoundException(e);
                         } catch (AttachmentInvalidException e) {
                         } catch (GroupNotFoundException e) {
                             handleGroupNotFoundException(e);
                         } catch (AttachmentInvalidException e) {
-                            System.err.println("Failed to add attachment (\"" + e.getAttachment() + "\"): " + e.getMessage());
+                            System.err.println("Failed to add attachment: " + e.getMessage());
                             System.err.println("Aborting sending.");
                             System.exit(1);
                         }
                             System.err.println("Aborting sending.");
                             System.exit(1);
                         }
@@ -259,7 +259,7 @@ public class Main {
                     } catch (IOException e) {
                         handleIOException(e);
                     } catch (AttachmentInvalidException e) {
                     } catch (IOException e) {
                         handleIOException(e);
                     } catch (AttachmentInvalidException e) {
-                        System.err.println("Failed to add avatar attachment (\"" + e.getAttachment() + ") for group\": " + e.getMessage());
+                        System.err.println("Failed to add avatar attachment for group\": " + e.getMessage());
                         System.err.println("Aborting sending.");
                         System.exit(1);
                     } catch (GroupNotFoundException e) {
                         System.err.println("Aborting sending.");
                         System.exit(1);
                     } catch (GroupNotFoundException e) {
@@ -319,7 +319,7 @@ public class Main {
     }
 
     private static void handleGroupNotFoundException(GroupNotFoundException e) {
     }
 
     private static void handleGroupNotFoundException(GroupNotFoundException e) {
-        System.err.println("Failed to send to group \"" + Base64.encodeBytes(e.getGroupId()) + "\": Unknown group");
+        System.err.println("Failed to send to group: " + e.getMessage());
         System.err.println("Aborting sending.");
         System.exit(1);
     }
         System.err.println("Aborting sending.");
         System.exit(1);
     }