refactor: Moved exceptions into package `exceptions` - Moved classes
authorKai Moritz <kai@juplo.de>
Wed, 6 Sep 2023 21:38:15 +0000 (23:38 +0200)
committerKai Moritz <kai@juplo.de>
Fri, 26 Jan 2024 18:09:00 +0000 (19:09 +0100)
src/main/java/de/juplo/kafka/chat/backend/domain/InvalidUsernameException.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/domain/LoadInProgressException.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/domain/MessageMutationException.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/domain/ShardNotOwnedException.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/domain/UnknownChatroomException.java [deleted file]
src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java [new file with mode: 0644]
src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java [new file with mode: 0644]

diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/InvalidUsernameException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/InvalidUsernameException.java
deleted file mode 100644 (file)
index f9a9b12..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-package de.juplo.kafka.chat.backend.domain;
-
-import lombok.Getter;
-
-
-public class InvalidUsernameException extends RuntimeException
-{
-  @Getter
-  private final String username;
-
-  public InvalidUsernameException(String username)
-  {
-    super("Invalid username: " + username);
-    this.username = username;
-  }
-}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/LoadInProgressException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/LoadInProgressException.java
deleted file mode 100644 (file)
index d87e76d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package de.juplo.kafka.chat.backend.domain;
-
-
-public class LoadInProgressException extends IllegalStateException
-{
-  public LoadInProgressException()
-  {
-    super("Load in progress...");
-  }
-}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/MessageMutationException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/MessageMutationException.java
deleted file mode 100644 (file)
index 3f02792..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package de.juplo.kafka.chat.backend.domain;
-
-import lombok.Getter;
-
-
-public class MessageMutationException extends RuntimeException
-{
-  @Getter
-  private final Message existing;
-  @Getter
-  private final String mutatedText;
-
-  public MessageMutationException(Message existing, String mutatedText)
-  {
-    super("Messages are imutable!");
-    this.existing = existing;
-    this.mutatedText = mutatedText;
-  }
-}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ShardNotOwnedException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ShardNotOwnedException.java
deleted file mode 100644 (file)
index 3b63833..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-package de.juplo.kafka.chat.backend.domain;
-
-import lombok.Getter;
-
-
-public class ShardNotOwnedException extends IllegalStateException
-{
-  @Getter
-  private final int shard;
-
-
-  public ShardNotOwnedException(int shard)
-  {
-    super("This instance does not own the shard " + shard);
-    this.shard = shard;
-  }
-}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/UnknownChatroomException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/UnknownChatroomException.java
deleted file mode 100644 (file)
index 714c220..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-package de.juplo.kafka.chat.backend.domain;
-
-import lombok.Getter;
-
-import java.util.Arrays;
-import java.util.Optional;
-import java.util.UUID;
-import java.util.stream.Collectors;
-
-
-public class UnknownChatroomException extends IllegalStateException
-{
-  @Getter
-  private final UUID chatroomId;
-  @Getter
-  private final Optional<Integer> shard;
-  @Getter
-  private final Optional<int[]> ownedShards;
-
-  public UnknownChatroomException(UUID chatroomId)
-  {
-    super("Chatroom does not exist: " + chatroomId);
-    this.chatroomId = chatroomId;
-    this.shard = Optional.empty();
-    this.ownedShards = Optional.empty();
-  }
-
-  public UnknownChatroomException(UUID chatroomId, int shard, int[] ownedShards)
-  {
-    super(
-        "Chatroom does not exist (here): " +
-        chatroomId +
-        " shard=" +
-        shard +
-        ", owned=" +
-        Arrays
-            .stream(ownedShards)
-            .mapToObj(ownedShard -> Integer.toString(ownedShard))
-            .collect(Collectors.joining(",")));
-    this.chatroomId = chatroomId;
-    this.shard = Optional.of(shard);
-    this.ownedShards = Optional.of(ownedShards);
-  }
-}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/InvalidUsernameException.java
new file mode 100644 (file)
index 0000000..f9a9b12
--- /dev/null
@@ -0,0 +1,16 @@
+package de.juplo.kafka.chat.backend.domain;
+
+import lombok.Getter;
+
+
+public class InvalidUsernameException extends RuntimeException
+{
+  @Getter
+  private final String username;
+
+  public InvalidUsernameException(String username)
+  {
+    super("Invalid username: " + username);
+    this.username = username;
+  }
+}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/LoadInProgressException.java
new file mode 100644 (file)
index 0000000..d87e76d
--- /dev/null
@@ -0,0 +1,10 @@
+package de.juplo.kafka.chat.backend.domain;
+
+
+public class LoadInProgressException extends IllegalStateException
+{
+  public LoadInProgressException()
+  {
+    super("Load in progress...");
+  }
+}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/MessageMutationException.java
new file mode 100644 (file)
index 0000000..3f02792
--- /dev/null
@@ -0,0 +1,19 @@
+package de.juplo.kafka.chat.backend.domain;
+
+import lombok.Getter;
+
+
+public class MessageMutationException extends RuntimeException
+{
+  @Getter
+  private final Message existing;
+  @Getter
+  private final String mutatedText;
+
+  public MessageMutationException(Message existing, String mutatedText)
+  {
+    super("Messages are imutable!");
+    this.existing = existing;
+    this.mutatedText = mutatedText;
+  }
+}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/ShardNotOwnedException.java
new file mode 100644 (file)
index 0000000..3b63833
--- /dev/null
@@ -0,0 +1,17 @@
+package de.juplo.kafka.chat.backend.domain;
+
+import lombok.Getter;
+
+
+public class ShardNotOwnedException extends IllegalStateException
+{
+  @Getter
+  private final int shard;
+
+
+  public ShardNotOwnedException(int shard)
+  {
+    super("This instance does not own the shard " + shard);
+    this.shard = shard;
+  }
+}
diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java b/src/main/java/de/juplo/kafka/chat/backend/domain/exceptions/UnknownChatroomException.java
new file mode 100644 (file)
index 0000000..714c220
--- /dev/null
@@ -0,0 +1,44 @@
+package de.juplo.kafka.chat.backend.domain;
+
+import lombok.Getter;
+
+import java.util.Arrays;
+import java.util.Optional;
+import java.util.UUID;
+import java.util.stream.Collectors;
+
+
+public class UnknownChatroomException extends IllegalStateException
+{
+  @Getter
+  private final UUID chatroomId;
+  @Getter
+  private final Optional<Integer> shard;
+  @Getter
+  private final Optional<int[]> ownedShards;
+
+  public UnknownChatroomException(UUID chatroomId)
+  {
+    super("Chatroom does not exist: " + chatroomId);
+    this.chatroomId = chatroomId;
+    this.shard = Optional.empty();
+    this.ownedShards = Optional.empty();
+  }
+
+  public UnknownChatroomException(UUID chatroomId, int shard, int[] ownedShards)
+  {
+    super(
+        "Chatroom does not exist (here): " +
+        chatroomId +
+        " shard=" +
+        shard +
+        ", owned=" +
+        Arrays
+            .stream(ownedShards)
+            .mapToObj(ownedShard -> Integer.toString(ownedShard))
+            .collect(Collectors.joining(",")));
+    this.chatroomId = chatroomId;
+    this.shard = Optional.of(shard);
+    this.ownedShards = Optional.of(ownedShards);
+  }
+}