From ef1167b037973154f6cb0d5e3f58e44a54bf9a25 Mon Sep 17 00:00:00 2001 From: Steven van Beelen Date: Fri, 19 Mar 2021 11:04:12 +0100 Subject: [PATCH] Update Exception API - Introduce a DuplicateOrderLineException to signal whenever somebody wants to add the same product twice instead of using the increment command. - Introduce OrderAlreadyConfirmedException to signal whenever the order is confirmed, so that adding products and incrementing/decrementing their count is not possible once the order has been confirmed #BAEL-4767 --- .../coreapi/exceptions/DuplicateOrderLineException.java | 8 ++++++++ .../exceptions/OrderAlreadyConfirmedException.java | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/exceptions/DuplicateOrderLineException.java create mode 100644 axon/src/main/java/com/baeldung/axon/coreapi/exceptions/OrderAlreadyConfirmedException.java diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/DuplicateOrderLineException.java b/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/DuplicateOrderLineException.java new file mode 100644 index 0000000000..c8a62a6cf0 --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/DuplicateOrderLineException.java @@ -0,0 +1,8 @@ +package com.baeldung.axon.coreapi.exceptions; + +public class DuplicateOrderLineException extends IllegalStateException { + + public DuplicateOrderLineException(String productId) { + super("Cannot duplicate order line for product identifier [" + productId + "]"); + } +} diff --git a/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/OrderAlreadyConfirmedException.java b/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/OrderAlreadyConfirmedException.java new file mode 100644 index 0000000000..5a4d1cdaec --- /dev/null +++ b/axon/src/main/java/com/baeldung/axon/coreapi/exceptions/OrderAlreadyConfirmedException.java @@ -0,0 +1,8 @@ +package com.baeldung.axon.coreapi.exceptions; + +public class OrderAlreadyConfirmedException extends IllegalStateException { + + public OrderAlreadyConfirmedException(String orderId) { + super("Cannot perform operation because order [" + orderId + "] is already confirmed."); + } +}