Added application layer and blockchain implementation
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.rviewer.skeletons.application.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
@ControllerAdvice
|
||||
public class ControllerExceptionHandler {
|
||||
|
||||
public static final String INVALID_BODY = "Invalid body provided, check the payload.";
|
||||
|
||||
@ExceptionHandler(CartNotFoundException.class)
|
||||
public ResponseEntity<Object> handleCartNotFound(CartNotFoundException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@ExceptionHandler(CartAlreadyExistsException.class)
|
||||
public ResponseEntity<Object> handleCartAlreadyExists(CartAlreadyExistsException e) {
|
||||
return new ResponseEntity<>(e.getMessage(), HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
@ExceptionHandler({MethodArgumentNotValidException.class, HttpMessageNotReadableException.class})
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public ResponseEntity<Object> handleInvalidBody() {
|
||||
return new ResponseEntity<>(INVALID_BODY, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user