1
1
package com .univ .sohwakhaeng .global .common .advice ;
2
2
3
3
4
+ import com .univ .sohwakhaeng .enterprise .exception .EnterpriseNotFoundException ;
4
5
import com .univ .sohwakhaeng .global .common .dto .BaseResponse ;
5
6
import com .univ .sohwakhaeng .global .common .exception .ErrorCode ;
6
7
import com .univ .sohwakhaeng .global .common .exception .model .CustomException ;
7
8
import com .univ .sohwakhaeng .global .common .exception .model .RefreshTokenInvalidException ;
9
+ import com .univ .sohwakhaeng .payment .exception .PaymentFailException ;
8
10
import jakarta .servlet .http .HttpServletRequest ;
9
11
import lombok .extern .slf4j .Slf4j ;
10
12
import org .hibernate .service .spi .ServiceException ;
11
13
import org .springframework .http .HttpStatus ;
14
+ import org .springframework .http .HttpStatusCode ;
12
15
import org .springframework .http .ResponseEntity ;
13
16
import org .springframework .security .authentication .BadCredentialsException ;
14
17
import org .springframework .security .core .AuthenticationException ;
@@ -32,6 +35,13 @@ public class ControllerExceptionAdvice {
32
35
/**
33
36
* 400 BAD_REQUEST
34
37
*/
38
+ @ ExceptionHandler (PaymentFailException .class )
39
+ public ResponseEntity <BaseResponse > handleEnterpriseNotFoundException () {
40
+ ErrorCode errorCode = ErrorCode .PAYMENT_FAIL ;
41
+ BaseResponse response = BaseResponse .error (errorCode );
42
+ return new ResponseEntity <>(response , HttpStatusCode .valueOf (errorCode .getHttpStatusCode ()));
43
+ }
44
+
35
45
@ ResponseStatus (HttpStatus .BAD_REQUEST )
36
46
@ ExceptionHandler (MethodArgumentNotValidException .class )
37
47
protected BaseResponse handleMethodArgumentNotValidException (final MethodArgumentNotValidException e ) {
@@ -41,7 +51,7 @@ protected BaseResponse handleMethodArgumentNotValidException(final MethodArgumen
41
51
}
42
52
43
53
@ ResponseStatus (HttpStatus .BAD_REQUEST )
44
- @ ExceptionHandler (MissingRequestHeaderException .class )
54
+ @ ExceptionHandler ({ MissingRequestHeaderException .class } )
45
55
protected BaseResponse handleMissingRequestHeaderException (final MissingRequestHeaderException e ) {
46
56
log .error ("Missing Request Header: {}" , e .getMessage ());
47
57
return BaseResponse .error (ErrorCode .VALIDATION_REQUEST_HEADER_MISSING_EXCEPTION , String .format ("%s (%s)" , ErrorCode .VALIDATION_REQUEST_HEADER_MISSING_EXCEPTION .getMessage (), e .getHeaderName ()));
0 commit comments