summaryrefslogtreecommitdiffstats
path: root/dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java
diff options
context:
space:
mode:
Diffstat (limited to 'dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java')
-rw-r--r--dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java98
1 files changed, 48 insertions, 50 deletions
diff --git a/dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java b/dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java
index b559634..17c25b2 100644
--- a/dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java
+++ b/dcaedt_catalog/asdc/src/main/java/org/onap/sdc/dcae/errormng/BaseException.java
@@ -7,55 +7,53 @@ import org.springframework.web.client.HttpClientErrorException;
public class BaseException extends HttpClientErrorException {
- private static Gson gson = new Gson();
-
- protected RequestError requestError;
-
- public RequestError getRequestError() {
- return requestError;
- }
-
- public void setRequestError(RequestError requestError) {
- this.requestError = requestError;
- }
-
- public BaseException(HttpClientErrorException theError) {
- super(theError.getStatusCode());
- String body = theError.getResponseBodyAsString();
- if (body != null) {
- requestError = extractRequestError(body);
- }
- }
-
- public BaseException(HttpStatus status, RequestError re){
- super(status);
- requestError = re;
- }
-
- private RequestError extractRequestError(String error) {
- ResponseFormat responseFormat = gson.fromJson(error, ResponseFormat.class);
- return responseFormat.getRequestError();
- }
-
- @JsonIgnore
- public String getMessageId() {
- return requestError.getMessageId();
- }
-
- @JsonIgnore
- public String[] getVariables() {
- return requestError.getVariables();
- }
-
- @JsonIgnore
- public String getText(){
- return requestError.getText();
- }
-
- @Override
- @JsonIgnore
- public String getMessage() {
- return requestError.getFormattedMessage();
- }
+ private static final Gson gson = new Gson();
+
+ protected final transient RequestError requestError;
+
+ public BaseException(HttpClientErrorException theError) {
+ super(theError.getStatusCode());
+ String body = theError.getResponseBodyAsString();
+ if (body != null) {
+ requestError = extractRequestError(body);
+ } else {
+ requestError = null;
+ }
+ }
+
+ public BaseException(HttpStatus status, RequestError re){
+ super(status);
+ requestError = re;
+ }
+
+ public RequestError getRequestError() {
+ return requestError;
+ }
+
+ private RequestError extractRequestError(String error) {
+ ResponseFormat responseFormat = gson.fromJson(error, ResponseFormat.class);
+ return responseFormat.getRequestError();
+ }
+
+ @JsonIgnore
+ public String getMessageId() {
+ return requestError.getMessageId();
+ }
+
+ @JsonIgnore
+ public String[] getVariables() {
+ return requestError.getVariables();
+ }
+
+ @JsonIgnore
+ public String getText(){
+ return requestError.getText();
+ }
+
+ @Override
+ @JsonIgnore
+ public String getMessage() {
+ return requestError.getFormattedMessage();
+ }
} \ No newline at end of file