Skip to content

Commit 54825fe

Browse files
committed
Merge branch 'develop'
2 parents 84b00c0 + be67e26 commit 54825fe

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/main/java/com/longcoding/moon/exceptions/ExceptionAdvice.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.springframework.http.ResponseEntity;
1313
import org.springframework.web.bind.annotation.ControllerAdvice;
1414
import org.springframework.web.bind.annotation.ExceptionHandler;
15+
import org.springframework.web.context.request.async.AsyncRequestTimeoutException;
1516

1617
import javax.servlet.http.HttpServletRequest;
1718
import java.io.PrintWriter;
@@ -45,6 +46,15 @@ public ResponseEntity exception(Exception e, HttpServletRequest request) {
4546
return HttpHelper.newResponseEntityWithId(HttpStatus.INTERNAL_SERVER_ERROR, response);
4647
}
4748

49+
@ExceptionHandler(AsyncRequestTimeoutException.class)
50+
public ResponseEntity asyncRequestTimeoutException(Exception e, HttpServletRequest request) {
51+
log.error("{}", getStackTrace(e));
52+
ExceptionType exceptionType = ExceptionType.E_7104_OUTBOUND_SERVICE_REQUEST_TIME_OUT;
53+
setHttpResponseErrorCode(request, ExceptionType.E_7104_OUTBOUND_SERVICE_REQUEST_TIME_OUT.getCode());
54+
CommonResponseEntity response = CommonResponseEntity.generateException(exceptionType.getCode(), messageManager.getProperty(exceptionType.getCode()));
55+
return HttpHelper.newResponseEntityWithId(HttpStatus.REQUEST_TIMEOUT, response);
56+
}
57+
4858
@ExceptionHandler(RatelimitFailException.class)
4959
public ResponseEntity ratelimtFailException(RatelimitFailException e, HttpServletRequest request) {
5060
log.error("{}", getStackTrace(e));

src/main/java/com/longcoding/moon/exceptions/ExceptionType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public enum ExceptionType {
3636
E_1101_API_GATEWAY_IS_EXHAUSTED("1101", HttpStatus.SERVICE_UNAVAILABLE),
3737
E_1102_OUTBOUND_SERVICE_IS_NOT_UNSTABLE("1102", HttpStatus.GATEWAY_TIMEOUT),
3838
E_1103_OUTBOUND_SERVICE_CAPACITY_OVER("1103", HttpStatus.SERVICE_UNAVAILABLE),
39+
E_1104_OUTBOUND_SERVICE_REQUEST_TIME_OUT("1104", HttpStatus.REQUEST_TIMEOUT),
3940

4041
E_1200_FAIL_SERVICE_INFO_CONFIGURATION_INIT("1200", HttpStatus.INTERNAL_SERVER_ERROR),
4142
E_1201_FAIL_API_INFO_CONFIGURATION_INIT("1201", HttpStatus.INTERNAL_SERVER_ERROR),

src/main/resources/message/error-message_en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
1101: Internal Server Error. Proxy server is exhausted.
1818
1102: Internal Server Error. Outbound Service is unstable.
1919
1103: Went over service Capacity.
20+
1104: Request Timeout.
2021

2122
1200: Failed Configuration Init. Please check the service info configuration.
2223
1201: Failed Configuration Init. Please check the API info configuration.

0 commit comments

Comments
 (0)