|
|
|
|
@ -12,8 +12,6 @@ import org.springframework.web.reactive.function.client.WebClientResponseExcepti
|
|
|
|
|
import reactor.core.publisher.Mono;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class WebClientDepositService {
|
|
|
|
|
@ -78,17 +76,29 @@ public class WebClientDepositService {
|
|
|
|
|
|
|
|
|
|
private ApplicationExceptionMapper.APIError parseErrorDetails(WebClientResponseException e) {
|
|
|
|
|
String errorCode = null;
|
|
|
|
|
List<String> arguments = null;
|
|
|
|
|
Object[] arguments = new Object[0];
|
|
|
|
|
if (e.getResponseBodyAsString() != null) {
|
|
|
|
|
try {
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode errorNode = objectMapper.readTree(e.getResponseBodyAsString());
|
|
|
|
|
errorCode = errorNode.get("errorCode").asText();
|
|
|
|
|
arguments = Arrays.asList(objectMapper.convertValue(errorNode.get("arguments"), String[].class));
|
|
|
|
|
JsonNode errorCodeNode = errorNode.get("errorCode");
|
|
|
|
|
if (errorCodeNode != null && !errorCodeNode.isNull()) {
|
|
|
|
|
errorCode = errorCodeNode.asText();
|
|
|
|
|
} else {
|
|
|
|
|
JsonNode debugNode = errorNode.get("debugMessage");
|
|
|
|
|
errorCode = (debugNode != null && !debugNode.isNull()) ? debugNode.asText() : "ERR_REMOTE_" + e.getStatusCode().value();
|
|
|
|
|
}
|
|
|
|
|
JsonNode argsNode = errorNode.get("arguments");
|
|
|
|
|
if (argsNode != null && !argsNode.isNull()) {
|
|
|
|
|
arguments = objectMapper.convertValue(argsNode, String[].class);
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException ex) {
|
|
|
|
|
errorCode = "ERR_REMOTE_" + e.getStatusCode().value();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
errorCode = "ERR_REMOTE_" + e.getStatusCode().value();
|
|
|
|
|
}
|
|
|
|
|
return new ApplicationExceptionMapper.APIError(errorCode, arguments.toArray());
|
|
|
|
|
return new ApplicationExceptionMapper.APIError(errorCode, arguments);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|