Revert "Return 404 for missing user or post"

This reverts commit 68410c7fd1.
This commit is contained in:
tim
2025-07-14 18:37:08 +08:00
parent b7534afbf3
commit f4cedc3a4f

View File

@@ -1,6 +1,5 @@
package com.openisle.controller;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -17,15 +16,6 @@ public class GlobalExceptionHandler {
.body(Map.of("error", ex.getMessage(), "field", ex.getField()));
}
@ExceptionHandler(IllegalArgumentException.class)
public ResponseEntity<?> handleIllegalArgumentException(IllegalArgumentException ex) {
String msg = ex.getMessage();
if (msg != null && (msg.contains("User not found") || msg.contains("Post not found"))) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(Map.of("error", msg));
}
return ResponseEntity.badRequest().body(Map.of("error", msg));
}
@ExceptionHandler(Exception.class)
public ResponseEntity<?> handleException(Exception ex) {
return ResponseEntity.badRequest().body(Map.of("error", ex.getMessage()));