Added application layer and blockchain implementation

This commit is contained in:
droideparanoico
2022-10-08 12:27:21 +02:00
parent 63fb2fd1c6
commit 1a030c75b1
18 changed files with 140 additions and 41 deletions

View File

@@ -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);
}
}