From cd145d82cc6dcb66ea146170aa3aa8f230b9b88c Mon Sep 17 00:00:00 2001
From: sathish Ramesh
Date: Tue, 22 Oct 2024 21:28:30 +0530
Subject: [PATCH] feat:Business logic exception categorized as features
---
.../mdx/accessor/feature/ErrorDescriptor.java | 18 ++++------
.../mdx/accessor/feature/FeatureMapper.java | 20 -----------
.../accessor/transfer/TransfersException.java | 36 -------------------
3 files changed, 7 insertions(+), 67 deletions(-)
delete mode 100644 mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/FeatureMapper.java
delete mode 100644 mdx-models/src/main/java/com/mx/path/model/mdx/accessor/transfer/TransfersException.java
diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/ErrorDescriptor.java b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/ErrorDescriptor.java
index cfc3e114..a9c45c88 100644
--- a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/ErrorDescriptor.java
+++ b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/ErrorDescriptor.java
@@ -6,6 +6,7 @@
* This enum provides a centralized way to manage error descriptors used
* throughout the application. Each constant represents a specific error
* condition that may arise during application operations.
+ *
*
* Usage:
*
@@ -14,18 +15,13 @@
*
*/
public enum ErrorDescriptor {
- INSUFFICIENT_FUNDS("INSUFFICIENT_FUNDS"),
- ACCOUNT_NOT_FOUND("ACCOUNT_NOT_FOUND"),
- UNKNOWN_ERROR("UNKNOWN_ERROR");
+ INSUFFICIENT_FUNDS,
+ ACCOUNT_NOT_FOUND,
+ UNKNOWN_ERROR;
// todo: All the expected ErrorDescriptors will be added here.
- private final String descriptor;
-
- ErrorDescriptor(String descriptor) {
- this.descriptor = descriptor;
- }
-
- public String getDescriptor() {
- return descriptor;
+ @Override
+ public String toString() {
+ return name();
}
}
diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/FeatureMapper.java b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/FeatureMapper.java
deleted file mode 100644
index 5f750653..00000000
--- a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/FeatureMapper.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.mx.path.model.mdx.accessor.feature;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.mx.path.core.common.request.Feature;
-
-public class FeatureMapper {
-
- private static final Map FEATURE_NAMES = new HashMap<>();
-
- static {
- FEATURE_NAMES.put(Feature.TRANSFERS, "transfers");
- FEATURE_NAMES.put(Feature.REMOTE_DEPOSITS, "remote_deposits");
- }
-
- public static String getFeatureName(Feature feature) {
- return FEATURE_NAMES.get(feature);
- }
-}
diff --git a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/transfer/TransfersException.java b/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/transfer/TransfersException.java
deleted file mode 100644
index a427f64b..00000000
--- a/mdx-models/src/main/java/com/mx/path/model/mdx/accessor/transfer/TransfersException.java
+++ /dev/null
@@ -1,36 +0,0 @@
-
-package com.mx.path.model.mdx.accessor.transfer;
-
-import com.mx.path.core.common.request.Feature;
-import com.mx.path.model.mdx.accessor.feature.ErrorDescriptor;
-import com.mx.path.model.mdx.accessor.feature.FeatureException;
-import com.mx.path.model.mdx.accessor.feature.FeatureMapper;
-
-/**
- * Exception thrown when there is an error related to transfers.
- *
- * This base exception for transfers sets the appropriate feature name
- * and allows for error descriptors to be specified for more specific
- * transfer-related errors.
- *
- */
-public class TransfersException extends FeatureException {
-
- /**
- * Constructs a TransfersException with a specific user message and error descriptor.
- *
- * @param userMessage The message to be displayed to the user.
- * @param errorDescriptor The error descriptor for this exception.
- */
- public TransfersException(String userMessage, ErrorDescriptor errorDescriptor) {
- super(userMessage, Feature.TRANSFERS, errorDescriptor.getDescriptor());
- }
-
- /**
- * Returns the name of the feature associated with this exception.
- */
- @Override
- protected String getFeatureName() {
- return FeatureMapper.getFeatureName(Feature.TRANSFERS);
- }
-}