chore(release): v1.1 #2

Merged
bedroomghost merged 6 commits from develop into main 2025-04-21 19:39:49 +00:00
Showing only changes of commit 0258f2b5d1 - Show all commits

View File

@ -2,13 +2,16 @@ package com.techivw.webprice.infrastructure.in.controllers.handlers;
import com.techivw.webprice.application.exceptions.NotFoundException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static org.springframework.http.HttpStatus.BAD_REQUEST;
import static org.springframework.http.HttpStatus.NOT_FOUND;
@RestControllerAdvice
@ -24,4 +27,27 @@ public class AdapterExceptionHandler {
return new ResponseEntity<>(body, NOT_FOUND);
}
@ExceptionHandler(MissingServletRequestParameterException.class)
public ResponseEntity<Map<String, Object>> handleMissingParamException(MissingServletRequestParameterException ex) {
Map<String, Object> body = new HashMap<>();
body.put("timestamp", new Date());
body.put("status", BAD_REQUEST.value());
body.put("error", "Bad Request");
body.put("message", "Required parameter '" + ex.getParameterName() + "' is missing");
return new ResponseEntity<>(body, BAD_REQUEST);
}
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public ResponseEntity<Map<String, Object>> handleTypeMismatchException(MethodArgumentTypeMismatchException ex) {
Map<String, Object> body = new HashMap<>();
body.put("timestamp", new Date());
body.put("status", BAD_REQUEST.value());
body.put("error", "Bad Request");
body.put("message", "Parameter '" + ex.getName() + "' has invalid format.");
return new ResponseEntity<>(body, BAD_REQUEST);
}
}