mirror of
https://github.com/headporter81/specialsource-homepage-backend.git
synced 2026-12-06 07:41:09 +09:00
fix : 컨트롤러 진입 전 오류(멀티파트 해석 등)도 원인을 응답에 담아 화면에 표시
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 1m4s
SpecialSource Backend CI/CD / build-and-deploy (push) Successful in 1m4s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1fd7d581bd
commit
f4b571747d
1 file changed
+24
@@ -0,0 +1,24 @@
|
||||
package company.specialsource.config;
|
||||
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.ErrorResponse;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
// 업로드 500 원인 찾기용: 컨트롤러 진입 전(멀티파트 해석 등)에 난 오류도 원인을 응답에 담아 화면까지 전달
|
||||
// ErrorResponse(400·404 같은 스프링 표준 오류)는 원래대로 두고, 그 밖의 예외만
|
||||
@RestControllerAdvice
|
||||
public class UploadErrorAdvice {
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<?> handle(Exception e) throws Exception {
|
||||
if (e instanceof ErrorResponse) throw e;
|
||||
e.printStackTrace();
|
||||
Throwable root = e;
|
||||
while (root.getCause() != null && root.getCause() != root) root = root.getCause();
|
||||
String msg = root == e ? e.toString() : e + " ← " + root;
|
||||
return ResponseEntity.status(500).body(Map.of("error", "서버 처리 실패: " + msg));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user