]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/ReceiveCommand.java
Implement textStyles for sending and receiving
[signal-cli] / src / main / java / org / asamk / signal / commands / ReceiveCommand.java
index 79d0ee1dad5dad95058c98fa1820ce66d434bec4..ab65f8377eeccf8fb1181f62ecffc9ceb38089f3 100644 (file)
@@ -10,8 +10,10 @@ import org.asamk.signal.OutputType;
 import org.asamk.signal.ReceiveMessageHandler;
 import org.asamk.signal.commands.exceptions.CommandException;
 import org.asamk.signal.commands.exceptions.IOErrorException;
+import org.asamk.signal.commands.exceptions.UserErrorException;
 import org.asamk.signal.json.JsonReceiveMessageHandler;
 import org.asamk.signal.manager.Manager;
+import org.asamk.signal.manager.api.AlreadyReceivingException;
 import org.asamk.signal.manager.api.ReceiveConfig;
 import org.asamk.signal.output.JsonWriter;
 import org.asamk.signal.output.OutputWriter;
@@ -79,6 +81,8 @@ public class ReceiveCommand implements LocalCommand, JsonRpcSingleCommand<Receiv
             m.receiveMessages(Optional.ofNullable(duration), Optional.ofNullable(maxMessages), handler);
         } catch (IOException e) {
             throw new IOErrorException("Error while receiving messages: " + e.getMessage(), e);
+        } catch (AlreadyReceivingException e) {
+            throw new UserErrorException("Receive command cannot be used if messages are already being received.", e);
         }
     }
 
@@ -103,6 +107,8 @@ public class ReceiveCommand implements LocalCommand, JsonRpcSingleCommand<Receiv
             jsonWriter.write(messages);
         } catch (IOException e) {
             throw new IOErrorException("Error while receiving messages: " + e.getMessage(), e);
+        } catch (AlreadyReceivingException e) {
+            throw new UserErrorException("Receive command cannot be used if messages are already being received.", e);
         }
     }