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.WorkflowNotFoundException;
8 import org.springframework.http.ResponseEntity;
9 import org.springframework.web.bind.annotation.ControllerAdvice;
10 import org.springframework.web.bind.annotation.ExceptionHandler;
11 import org.springframework.web.bind.annotation.RestController;
12 import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
16 public class CustomizedResponseEntityExceptionHandler extends ResponseEntityExceptionHandler {
18 @ExceptionHandler(UniqueValueViolationException.class)
19 public final ResponseEntity<String> handleUniqueValueViolationException(
20 UniqueValueViolationException exception) {
21 return new ResponseEntity<>(exception.getMessage(), UNPROCESSABLE_ENTITY);
24 @ExceptionHandler(WorkflowNotFoundException.class)
25 public final ResponseEntity<String> handleWorkflowNotFoundException(
26 WorkflowNotFoundException exception) {
27 return new ResponseEntity<>(exception.getMessage(), NOT_FOUND);