|
|
|
@ -1,23 +1,19 @@
|
|
|
|
|
package kr.xit.core.spring.util.error;
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import io.netty.channel.ConnectTimeoutException;
|
|
|
|
|
import io.netty.handler.timeout.ReadTimeoutException;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
|
|
|
|
|
import kr.xit.core.exception.BizRuntimeException;
|
|
|
|
|
import kr.xit.core.model.ApiResponseDTO;
|
|
|
|
|
import kr.xit.core.model.ErrorDTO;
|
|
|
|
|
import kr.xit.core.support.utils.Checks;
|
|
|
|
|
import kr.xit.core.support.utils.JsonUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
|
|
|
|
|
|
|
|
|
import io.netty.channel.ConnectTimeoutException;
|
|
|
|
|
import io.netty.handler.timeout.ReadTimeoutException;
|
|
|
|
|
import kr.xit.core.model.ErrorDTO;
|
|
|
|
|
import kr.xit.core.support.utils.Checks;
|
|
|
|
|
import kr.xit.core.support.utils.JsonUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <pre>
|
|
|
|
|
* description :
|
|
|
|
@ -35,7 +31,7 @@ import kr.xit.core.support.utils.JsonUtils;
|
|
|
|
|
*/
|
|
|
|
|
public class ErrorParse {
|
|
|
|
|
|
|
|
|
|
public static Map<String,Object> extractError(final Throwable e){
|
|
|
|
|
public static ApiResponseDTO extractError(final Throwable e){
|
|
|
|
|
String errCode = String.valueOf(HttpStatus.INTERNAL_SERVER_ERROR.value());
|
|
|
|
|
String message = Checks.isNotNull(e) ? e.getLocalizedMessage() : StringUtils.EMPTY;
|
|
|
|
|
HttpStatus httpStatus = null;
|
|
|
|
@ -93,15 +89,11 @@ public class ErrorParse {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
private static Map<String, Object> getStringObjectMap(String errCode, String message, HttpStatus httpStatus) {
|
|
|
|
|
Map<String, Object> errorMap = new HashMap<>();
|
|
|
|
|
errorMap.put("code", errCode);
|
|
|
|
|
errorMap.put("message", message);
|
|
|
|
|
errorMap.put("httpStatus", httpStatus);
|
|
|
|
|
return errorMap;
|
|
|
|
|
private static ApiResponseDTO getStringObjectMap(String errCode, String message, HttpStatus httpStatus) {
|
|
|
|
|
return ApiResponseDTO.error(errCode, message, httpStatus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Map<String, Object> getTimeoutException(){
|
|
|
|
|
private static ApiResponseDTO getTimeoutException(){
|
|
|
|
|
return getStringObjectMap(
|
|
|
|
|
String.valueOf(HttpStatus.REQUEST_TIMEOUT.value()),
|
|
|
|
|
HttpStatus.REQUEST_TIMEOUT.getReasonPhrase(),
|
|
|
|
|