aboutsummaryrefslogtreecommitdiffstats
path: root/cps-nf-proxy-rest
diff options
context:
space:
mode:
Diffstat (limited to 'cps-nf-proxy-rest')
-rwxr-xr-xcps-nf-proxy-rest/pom.xml4
-rw-r--r--cps-nf-proxy-rest/src/main/java/org/onap/cps/nfproxy/rest/exceptions/NfProxyRestExceptionHandler.java23
2 files changed, 7 insertions, 20 deletions
diff --git a/cps-nf-proxy-rest/pom.xml b/cps-nf-proxy-rest/pom.xml
index b74cf6ec6f..04dfa9a317 100755
--- a/cps-nf-proxy-rest/pom.xml
+++ b/cps-nf-proxy-rest/pom.xml
@@ -46,10 +46,6 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- </dependency>
<!-- T E S T D E P E N D E N C I E S -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
diff --git a/cps-nf-proxy-rest/src/main/java/org/onap/cps/nfproxy/rest/exceptions/NfProxyRestExceptionHandler.java b/cps-nf-proxy-rest/src/main/java/org/onap/cps/nfproxy/rest/exceptions/NfProxyRestExceptionHandler.java
index 96a1cb267d..9a90f55de9 100644
--- a/cps-nf-proxy-rest/src/main/java/org/onap/cps/nfproxy/rest/exceptions/NfProxyRestExceptionHandler.java
+++ b/cps-nf-proxy-rest/src/main/java/org/onap/cps/nfproxy/rest/exceptions/NfProxyRestExceptionHandler.java
@@ -22,7 +22,6 @@ package org.onap.cps.nfproxy.rest.exceptions;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.exception.ExceptionUtils;
import org.onap.cps.nfproxy.rest.controller.NfProxyController;
import org.onap.cps.nfproxy.rest.model.ErrorMessage;
import org.onap.cps.spi.exceptions.CpsException;
@@ -53,26 +52,18 @@ public class NfProxyRestExceptionHandler {
@ExceptionHandler({CpsException.class})
public static ResponseEntity<Object> handleAnyOtherCpsExceptions(final CpsException exception) {
- return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception.getMessage(), extractDetails(exception));
+ return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception);
}
private static ResponseEntity<Object> buildErrorResponse(final HttpStatus status, final Exception exception) {
- return buildErrorResponse(status, exception.getMessage(), ExceptionUtils.getStackTrace(exception));
- }
-
- private static ResponseEntity<Object> buildErrorResponse(final HttpStatus status, final String message,
- final String details) {
- log.error("An error has occurred : {} Status: {} Details: {}", message, status, details);
+ if (exception.getCause() != null || !(exception instanceof CpsException)) {
+ log.error("Exception occurred", exception);
+ }
final ErrorMessage errorMessage = new ErrorMessage();
errorMessage.setStatus(status.toString());
- errorMessage.setMessage(message);
- errorMessage.setDetails(details);
+ errorMessage.setMessage(exception.getMessage());
+ errorMessage.setDetails(exception instanceof CpsException ? ((CpsException) exception).getDetails() :
+ "Check logs for details.");
return new ResponseEntity<>(errorMessage, status);
}
-
- private static String extractDetails(final CpsException exception) {
- return exception.getCause() == null
- ? exception.getDetails()
- : ExceptionUtils.getStackTrace(exception.getCause());
- }
}