complete level 5 track 1
This commit is contained in:
+7
@@ -12,6 +12,7 @@ import org.springframework.transaction.CannotCreateTransactionException;
|
||||
import org.springframework.web.HttpMediaTypeNotSupportedException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.MissingRequestHeaderException;
|
||||
import org.springframework.web.bind.MissingServletRequestParameterException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@@ -138,6 +139,12 @@ public class GlobalExceptionHandler {
|
||||
"Database error", req);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MissingRequestHeaderException.class)
|
||||
public ResponseEntity<ErrorDTO> missingHeader(MissingRequestHeaderException e, HttpServletRequest req) {
|
||||
return respond(HttpStatus.BAD_REQUEST, ErrorErrorDTO.CodeEnum.INVALID_REQUEST,
|
||||
"Missing header: " + e.getHeaderName(), req);
|
||||
}
|
||||
|
||||
private ResponseEntity<ErrorDTO> respond(HttpStatus status,
|
||||
ErrorErrorDTO.CodeEnum code,
|
||||
String message,
|
||||
|
||||
Reference in New Issue
Block a user