|
|
@ -10,7 +10,6 @@ import kr.xit.core.model.ErrorDTO;
|
|
|
|
import kr.xit.core.support.utils.Checks;
|
|
|
|
import kr.xit.core.support.utils.Checks;
|
|
|
|
import kr.xit.core.support.utils.JsonUtils;
|
|
|
|
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.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
|
|
|
import org.springframework.web.reactive.function.client.WebClientRequestException;
|
|
|
|
|
|
|
|
|
|
|
@ -38,19 +37,25 @@ public class ErrorParse {
|
|
|
|
|
|
|
|
|
|
|
|
if(e instanceof BizRuntimeException) {
|
|
|
|
if(e instanceof BizRuntimeException) {
|
|
|
|
BizRuntimeException be = (BizRuntimeException)e;
|
|
|
|
BizRuntimeException be = (BizRuntimeException)e;
|
|
|
|
return getStringObjectMap(be.getCode(), be.getMessage(), HttpStatus.BAD_REQUEST);
|
|
|
|
return ApiResponseDTO.error(be.getCode(), be.getMessage(), HttpStatus.BAD_REQUEST);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(e instanceof ClientError) {
|
|
|
|
if(e instanceof ClientError) {
|
|
|
|
ClientError ce = (ClientError)e;
|
|
|
|
ClientError ce = (ClientError)e;
|
|
|
|
ErrorDTO error = JsonUtils.toObject(ce.getBody(), ErrorDTO.class);
|
|
|
|
if(JsonUtils.isJson(ce.getBody())){
|
|
|
|
return getStringObjectMap(Objects.requireNonNull(error).getErrorCode(), error.getErrorMessage(), ce.getStatus());
|
|
|
|
ErrorDTO error = JsonUtils.toObject(ce.getBody(), ErrorDTO.class);
|
|
|
|
|
|
|
|
return ApiResponseDTO.error(Objects.requireNonNull(error).getErrorCode(), error.getErrorMessage(), ce.getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ApiResponseDTO.error(String.valueOf(ce.getStatus().value()), ce.getBody(), ce.getStatus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(e instanceof ServerError) {
|
|
|
|
if(e instanceof ServerError) {
|
|
|
|
ServerError ce = (ServerError) e;
|
|
|
|
ServerError ce = (ServerError) e;
|
|
|
|
ErrorDTO error = JsonUtils.toObject(ce.getBody(), ErrorDTO.class);
|
|
|
|
if(JsonUtils.isJson(ce.getBody())){
|
|
|
|
return getStringObjectMap(Objects.requireNonNull(error).getErrorCode(), error.getErrorMessage(), ce.getStatus());
|
|
|
|
ErrorDTO error = JsonUtils.toObject(ce.getBody(), ErrorDTO.class);
|
|
|
|
|
|
|
|
return ApiResponseDTO.error(Objects.requireNonNull(error).getErrorCode(), error.getErrorMessage(), ce.getStatus());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ApiResponseDTO.error(String.valueOf(ce.getStatus().value()), ce.getBody(), ce.getStatus());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Async(React) Exception 처리
|
|
|
|
// Async(React) Exception 처리
|
|
|
@ -85,16 +90,11 @@ public class ErrorParse {
|
|
|
|
message = e.getCause().getMessage();
|
|
|
|
message = e.getCause().getMessage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return getStringObjectMap(errCode, message, httpStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
|
|
|
private static ApiResponseDTO getStringObjectMap(String errCode, String message, HttpStatus httpStatus) {
|
|
|
|
|
|
|
|
return ApiResponseDTO.error(errCode, message, httpStatus);
|
|
|
|
return ApiResponseDTO.error(errCode, message, httpStatus);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static ApiResponseDTO getTimeoutException(){
|
|
|
|
private static ApiResponseDTO getTimeoutException(){
|
|
|
|
return getStringObjectMap(
|
|
|
|
return ApiResponseDTO.error(
|
|
|
|
String.valueOf(HttpStatus.REQUEST_TIMEOUT.value()),
|
|
|
|
String.valueOf(HttpStatus.REQUEST_TIMEOUT.value()),
|
|
|
|
HttpStatus.REQUEST_TIMEOUT.getReasonPhrase(),
|
|
|
|
HttpStatus.REQUEST_TIMEOUT.getReasonPhrase(),
|
|
|
|
HttpStatus.REQUEST_TIMEOUT);
|
|
|
|
HttpStatus.REQUEST_TIMEOUT);
|
|
|
|