@@ -39,6 +39,7 @@ public class GlobalExceptionHandler {
39
39
@ ExceptionHandler (MissingServletRequestParameterException .class )
40
40
protected ErrorResponse handleMissingServletRequestParameter (MissingServletRequestParameterException exception ) {
41
41
String errorMessage = String .format ("필수 파라미터 '%s'가 누락되었습니다." , exception .getParameterName ());
42
+
42
43
log .warn ("Required request parameter is missing: {}" , exception .getParameterName ());
43
44
44
45
return new ErrorResponse (errorMessage );
@@ -48,12 +49,11 @@ protected ErrorResponse handleMissingServletRequestParameter(MissingServletReque
48
49
@ ResponseStatus (HttpStatus .BAD_REQUEST )
49
50
@ ExceptionHandler (MethodArgumentTypeMismatchException .class )
50
51
protected ErrorResponse handleMethodArgumentTypeMismatch (MethodArgumentTypeMismatchException exception ) {
51
- String errorMessage ;
52
- log .warn ("Type mismatch for parameter: {}. Required type: {}" , exception .getName (),
52
+ String errorMessage = String .format ("파라미터 '%s'의 형식이 올바르지 않습니다. 예상 타입: %s" , exception .getName (),
53
53
requireNonNull (exception .getRequiredType ()).getSimpleName ());
54
54
55
- errorMessage = String . format ( "파라미터 '%s'의 형식이 올바르지 않습니다. 예상 타입: %s " , exception .getName (),
56
- exception .getRequiredType ().getSimpleName ());
55
+ log . warn ( "Type mismatch for parameter: {}. Required type: {} " , exception .getName (),
56
+ requireNonNull ( exception .getRequiredType () ).getSimpleName ());
57
57
58
58
return new ErrorResponse (errorMessage );
59
59
}
@@ -62,15 +62,14 @@ protected ErrorResponse handleMethodArgumentTypeMismatch(MethodArgumentTypeMisma
62
62
@ ResponseStatus (HttpStatus .BAD_REQUEST )
63
63
@ ExceptionHandler (ConstraintViolationException .class )
64
64
protected ErrorResponse handleConstraintViolationException (ConstraintViolationException exception ) {
65
- log .warn ("Constraint violation: {}" , exception .getMessage ());
66
-
67
65
List <String > errors = exception .getConstraintViolations ()
68
66
.stream ()
69
67
.map (violation -> violation .getPropertyPath () + ": " + violation .getMessage ())
70
68
.toList ();
71
-
72
69
String errorMessage = String .join (", " , errors );
73
70
71
+ log .warn ("Constraint violation: {}" , exception .getMessage ());
72
+
74
73
return new ErrorResponse ("입력값이 유효하지 않습니다: " + errorMessage );
75
74
}
76
75
@@ -120,6 +119,7 @@ protected ErrorResponse handleRuntimeException(RuntimeException exception) {
120
119
121
120
String errorKeyInfo = String .format (ERROR_KEY_FORMAT , sb );
122
121
String exceptionTypeInfo = String .format (EXCEPTION_CLASS_TYPE_MESSAGE_FORMANT , exception .getClass ());
122
+
123
123
log .error ("{}{}{}" , exception .getMessage (), errorKeyInfo , exceptionTypeInfo );
124
124
125
125
return new ErrorResponse (DEFAULT_ERROR_MESSAGE + errorKeyInfo );
0 commit comments