|
|
|
@ -10,7 +10,6 @@ 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.web.reactive.function.client.WebClientRequestException;
|
|
|
|
|
|
|
|
|
@ -38,19 +37,25 @@ public class ErrorParse {
|
|
|
|
|
|
|
|
|
|
if(e instanceof BizRuntimeException) {
|
|
|
|
|
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) {
|
|
|
|
|
ClientError ce = (ClientError)e;
|
|
|
|
|
if(JsonUtils.isJson(ce.getBody())){
|
|
|
|
|
ErrorDTO error = JsonUtils.toObject(ce.getBody(), ErrorDTO.class);
|
|
|
|
|
return getStringObjectMap(Objects.requireNonNull(error).getErrorCode(), error.getErrorMessage(), ce.getStatus());
|
|
|
|
|
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) {
|
|
|
|
|
ServerError ce = (ServerError) e;
|
|
|
|
|
if(JsonUtils.isJson(ce.getBody())){
|
|
|
|
|
ErrorDTO error = JsonUtils.toObject(ce.getBody(), ErrorDTO.class);
|
|
|
|
|
return getStringObjectMap(Objects.requireNonNull(error).getErrorCode(), error.getErrorMessage(), ce.getStatus());
|
|
|
|
|
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 처리
|
|
|
|
@ -85,16 +90,11 @@ public class ErrorParse {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static ApiResponseDTO getTimeoutException(){
|
|
|
|
|
return getStringObjectMap(
|
|
|
|
|
return ApiResponseDTO.error(
|
|
|
|
|
String.valueOf(HttpStatus.REQUEST_TIMEOUT.value()),
|
|
|
|
|
HttpStatus.REQUEST_TIMEOUT.getReasonPhrase(),
|
|
|
|
|
HttpStatus.REQUEST_TIMEOUT);
|
|
|
|
|