mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-22 16:21:15 +08:00
Revert "Return 404 for missing user or post"
This reverts commit 68410c7fd1.
This commit is contained in:
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user