]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/JsonWriter.java
Add CommandException to abstract cli return codes for errors
[signal-cli] / src / main / java / org / asamk / signal / JsonWriter.java
index 8aed44875cdc2d0f76498da7012849989aa3ae86..e7549adf8bcb4d1c13231adb7a4a201c7e317bf6 100644 (file)
@@ -26,14 +26,18 @@ public class JsonWriter {
         objectMapper.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);
     }
 
-    public void write(final Object object) throws IOException {
+    public void write(final Object object) {
         try {
-            objectMapper.writeValue(writer, object);
-        } catch (JsonProcessingException e) {
-            // Some issue with json serialization, probably caused by a bug
+            try {
+                objectMapper.writeValue(writer, object);
+            } catch (JsonProcessingException e) {
+                // Some issue with json serialization, probably caused by a bug
+                throw new AssertionError(e);
+            }
+            writer.write(System.lineSeparator());
+            writer.flush();
+        } catch (IOException e) {
             throw new AssertionError(e);
         }
-        writer.write(System.lineSeparator());
-        writer.flush();
     }
 }