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