Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
Issue #857
  • Loading branch information
rsoika committed Apr 2, 2024
1 parent 0328b53 commit 2d9e697
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 46 deletions.
Expand Up @@ -37,7 +37,6 @@
public class PluginException extends WorkflowException {

private static final long serialVersionUID = 1L;
private java.lang.Object[] params = null;

public PluginException(String aErrorContext, String aErrorCode, String message) {
super(aErrorContext, aErrorCode, message);
Expand All @@ -56,22 +55,4 @@ public PluginException(String aErrorContext, String aErrorCode, String message,
this.params = params;
}

public Object[] getErrorParameters() {
return params;
}

protected void setErrorParameters(java.lang.Object[] aparams) {
this.params = aparams;
}

@Override
public String formatErrorMessageWithParameters(String message){
if (params != null && params.length > 0) {
for (int i = 0; i < params.length; i++) {
message = message.replace("{" + i + "}", params[i].toString());
}
}

return message;
}
}
Expand Up @@ -41,32 +41,28 @@ public abstract class WorkflowException extends Exception {

protected String errorContext = "UNDEFINED";
protected String errorCode = "UNDEFINED";
protected java.lang.Object[] params = null;

public WorkflowException(String aErrorCode, String message) {
super(message);
errorCode = aErrorCode;

}

public WorkflowException(String aErrorContext, String aErrorCode, String message) {
super(message);
errorContext = aErrorContext;
errorCode = aErrorCode;

}

public WorkflowException(String aErrorContext, String aErrorCode, String message, Exception e) {
super(message, e);
errorContext = aErrorContext;
errorCode = aErrorCode;

}

public WorkflowException(String aErrorCode, String message, Exception e) {
super(message, e);

errorCode = aErrorCode;

}

public String getErrorContext() {
Expand All @@ -85,7 +81,20 @@ public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}

public String formatErrorMessageWithParameters(String message){
public Object[] getErrorParameters() {
return params;
}

protected void setErrorParameters(java.lang.Object[] aparams) {
this.params = aparams;
}

public String formatErrorMessageWithParameters(String message) {
if (params != null && params.length > 0) {
for (int i = 0; i < params.length; i++) {
message = message.replace("{" + i + "}", params[i].toString());
}
}
return message;
}
}
Expand Up @@ -40,7 +40,6 @@
public class ValidationException extends WorkflowException {

private static final long serialVersionUID = 1L;
private java.lang.Object[] params = null;

public ValidationException(String aErrorContext, String aErrorCode, String message) {
super(aErrorContext, aErrorCode, message);
Expand All @@ -52,26 +51,7 @@ public ValidationException(String aErrorContext, String aErrorCode, String messa

public ValidationException(String aErrorContext, String aErrorCode, String message, Object[] params) {
super(aErrorContext, aErrorCode, message);
this.params = params;
}

public java.lang.Object[] getErrorParameters() {
return params;
}

protected void setErrorParameters(Object[] aparams) {
this.params = aparams;
}

@Override
public String formatErrorMessageWithParameters(String message){
if (params != null && params.length > 0) {
for (int i = 0; i < params.length; i++) {
message = message.replace("{" + i + "}", params[i].toString());
}
}

return message;
this.setErrorParameters(params);
}

}

0 comments on commit 2d9e697

Please sign in to comment.