1 package org.onap.sdc.workflow.api.exceptionshandlers;
3 import static org.springframework.http.HttpStatus.NOT_FOUND;
4 import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
6 import org.onap.sdc.workflow.services.exceptions.UniqueValueViolationException;
7 import org.onap.sdc.workflow.services.exceptions.VersionNotFoundException;
8 import org.onap.sdc.workflow.services.exceptions.WorkflowNotFoundException;
9 import org.springframework.http.ResponseEntity;
10 import org.springframework.web.bind.annotation.ControllerAdvice;
11 import org.springframework.web.bind.annotation.ExceptionHandler;
12 import org.springframework.web.bind.annotation.RestController;
13 import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
17 public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
19 @ExceptionHandler(UniqueValueViolationException.class)
20 public final ResponseEntity<String> handleUniqueValueViolationException(
21 UniqueValueViolationException exception) {
22 return new ResponseEntity<>(exception.getMessage(), UNPROCESSABLE_ENTITY);
25 @ExceptionHandler({WorkflowNotFoundException.class, VersionNotFoundException.class})
26 public final ResponseEntity<String> handleWorkflowNotFoundException(
27 Exception exception) {
28 return new ResponseEntity<>(exception.getMessage(), NOT_FOUND);