From 91d5385dbd54c5f4fc538df1e0581e094ac3db8e Mon Sep 17 00:00:00 2001 From: MK13 Date: Sun, 12 May 2019 11:13:22 +0200 Subject: [PATCH] Handle duplicate account key issue gracefully Change transaction propagation to SUPPORTS for that as otherwise an UnexpectedRollbackException gets thrown --- src/main/java/de/financer/ResponseReason.java | 3 ++- src/main/resources/i18n/message.properties | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/financer/ResponseReason.java b/src/main/java/de/financer/ResponseReason.java index 88532a1..01a1025 100644 --- a/src/main/java/de/financer/ResponseReason.java +++ b/src/main/java/de/financer/ResponseReason.java @@ -29,7 +29,8 @@ public enum ResponseReason { MISSING_TRANSACTION_ID(HttpStatus.INTERNAL_SERVER_ERROR), INVALID_TRANSACTION_ID(HttpStatus.INTERNAL_SERVER_ERROR), TRANSACTION_NOT_FOUND(HttpStatus.INTERNAL_SERVER_ERROR), - ACCOUNT_NOT_FOUND(HttpStatus.INTERNAL_SERVER_ERROR); + ACCOUNT_NOT_FOUND(HttpStatus.INTERNAL_SERVER_ERROR), + DUPLICATE_ACCOUNT_KEY(HttpStatus.INTERNAL_SERVER_ERROR); private HttpStatus httpStatus; diff --git a/src/main/resources/i18n/message.properties b/src/main/resources/i18n/message.properties index b39ad02..791ee78 100644 --- a/src/main/resources/i18n/message.properties +++ b/src/main/resources/i18n/message.properties @@ -143,4 +143,5 @@ financer.error-message.RECURRING_TRANSACTION_NOT_FOUND=The recurring transaction financer.error-message.MISSING_TRANSACTION_ID=No transaction entered! financer.error-message.INVALID_TRANSACTION_ID=The transaction is not valid! financer.error-message.TRANSACTION_NOT_FOUND=The transaction could not be found! -financer.error-message.ACCOUNT_NOT_FOUND=The account could not be found! \ No newline at end of file +financer.error-message.ACCOUNT_NOT_FOUND=The account could not be found! +financer.error-message.DUPLICATE_ACCOUNT_KEY=An account with the given key already exists! \ No newline at end of file