X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cps-ncmp-rest%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fcps%2Fncmp%2Frest%2Fexceptions%2FNetworkCmProxyRestExceptionHandler.java;h=8c6f9f1d70df837189362da19e8c8f32b0fc4b1e;hb=e0873dde9816543a34818c1509b1aaa1c195a875;hp=ce9dd5a0278bfffa2da13f8e7abdea2b7b74622c;hpb=63132cec2c18363a8224646039cc23b6144d8e6c;p=cps.git diff --git a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java index ce9dd5a02..8c6f9f1d7 100755 --- a/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java +++ b/cps-ncmp-rest/src/main/java/org/onap/cps/ncmp/rest/exceptions/NetworkCmProxyRestExceptionHandler.java @@ -21,7 +21,9 @@ package org.onap.cps.ncmp.rest.exceptions; import lombok.extern.slf4j.Slf4j; +import org.onap.cps.ncmp.api.impl.exception.DmiRequestException; import org.onap.cps.ncmp.api.impl.exception.NcmpException; +import org.onap.cps.ncmp.api.impl.exception.ServerNcmpException; import org.onap.cps.ncmp.rest.controller.NetworkCmProxyController; import org.onap.cps.ncmp.rest.model.ErrorMessage; import org.onap.cps.spi.exceptions.CpsException; @@ -56,11 +58,16 @@ public class NetworkCmProxyRestExceptionHandler { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception); } - @ExceptionHandler({NcmpException.class}) - public static ResponseEntity handleNcmpExceptions(final NcmpException exception) { + @ExceptionHandler({ServerNcmpException.class}) + public static ResponseEntity handleServerNcmpExceptions(final ServerNcmpException exception) { return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception); } + @ExceptionHandler({DmiRequestException.class}) + public static ResponseEntity handleDmiRequestExceptions(final DmiRequestException exception) { + return buildErrorResponse(HttpStatus.BAD_REQUEST, exception); + } + private static ResponseEntity buildErrorResponse(final HttpStatus status, final Exception exception) { if (exception.getCause() != null || !(exception instanceof CpsException)) { log.error("Exception occurred", exception);