-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:Business logic exception categorized as features #266
Conversation
mdx-models/src/main/java/com/mx/path/model/mdx/accessor/ach_transfer/TransfersException.java
Outdated
Show resolved
Hide resolved
mdx-models/src/main/java/com/mx/path/model/mdx/accessor/feature/Feature.java
Outdated
Show resolved
Hide resolved
|
||
import com.mx.path.core.common.request.Feature; | ||
|
||
public class FeatureMapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a FeatureMapper class. The Feature enum contains these strings already. And it's overriding the toString() method to return the name. Could probably use that instead https://github.com/mxenabled/path-core/blob/master/common/src/main/java/com/mx/path/core/common/request/Feature.java#L113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature should just be provided as a constructor arg. No need to map anything.
* transfer-related errors. | ||
* </p> | ||
*/ | ||
public class TransfersException extends FeatureException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public class TransfersException extends FeatureException { | |
public class TransferException extends FeatureException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be more consistent to make there singular.
* Returns the name of the feature associated with this exception. | ||
*/ | ||
@Override | ||
protected String getFeatureName() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this. Just convert the enum to a string when placing in header.
protected String getFeatureName() { |
*/ | ||
public abstract class FeatureException extends PathRequestException { | ||
|
||
private final String feature; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private final String feature; | |
private final Feature feature; |
* Initializes headers for the exception. | ||
*/ | ||
private void initialize() { | ||
withHeader("MX-Feature", feature); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withHeader("MX-Feature", feature); | |
withHeader("MX-Feature", feature.toString()); |
public abstract class FeatureException extends PathRequestException { | ||
|
||
private final String feature; | ||
private final String errorDescriptor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this. Just store as an enum and convert to a string when placing in header.
private final String errorDescriptor; | |
private final ErrorDescriptor errorDescriptor; |
*/ | ||
private void initialize() { | ||
withHeader("MX-Feature", feature); | ||
withHeader("MX-Feature-Error", errorDescriptor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
withHeader("MX-Feature-Error", errorDescriptor); | |
withHeader("MX-Feature-Error", errorDescriptor).toString(); |
* @param errorDescriptor The error descriptor for this exception. | ||
*/ | ||
public TransfersException(String userMessage, ErrorDescriptor errorDescriptor) { | ||
super(userMessage, Feature.TRANSFERS, errorDescriptor.getDescriptor()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super(userMessage, Feature.TRANSFERS, errorDescriptor.getDescriptor()); | |
super(userMessage, Feature.TRANSFERS, errorDescriptor); |
private final String feature; | ||
private final String errorDescriptor; | ||
|
||
protected FeatureException(String userMessage, Feature feature, String errorDescriptor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protected FeatureException(String userMessage, Feature feature, String errorDescriptor) { | |
protected FeatureException(String userMessage, Feature feature, ErrorDescriptor errorDescriptor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good start. 👍
Summary of Changes
** Implemented Structured Exception Handling:**
Introduced Enums for Features and Error Descriptors:
Enhanced Clarity and Maintainability:
- Documentation: