Skip to content

Commit

Permalink
feat:Business logic exception categorized as features
Browse files Browse the repository at this point in the history
  • Loading branch information
sathish Ramesh committed Oct 21, 2024
1 parent 7fc4218 commit 22c4c54
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 36 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mx.path.model.mdx.accessor.feature;

import com.mx.path.core.common.exception.PathRequestException;
import com.mx.path.core.common.request.Feature;

/**
* Base class for exceptions related to features in the path-mdx-model project.
Expand All @@ -22,7 +23,7 @@ public abstract class FeatureException extends PathRequestException {

protected FeatureException(String userMessage, Feature feature, String errorDescriptor) {
super(userMessage);
this.feature = feature.getFeatureName();
this.feature = FeatureMapper.getFeatureName(feature);
this.errorDescriptor = errorDescriptor;
initialize();
}
Expand All @@ -41,5 +42,4 @@ private void initialize() {
withHeader("MX-Feature", feature);
withHeader("MX-Feature-Error", errorDescriptor);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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, String> 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);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.mx.path.model.mdx.accessor.ach_transfer;

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.Feature;
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.
Expand All @@ -29,6 +31,6 @@ public TransfersException(String userMessage, ErrorDescriptor errorDescriptor) {
*/
@Override
protected String getFeatureName() {
return Feature.TRANSFERS.getFeatureName();
return FeatureMapper.getFeatureName(Feature.TRANSFERS);
}
}

0 comments on commit 22c4c54

Please sign in to comment.