MCPcopy Index your code
hub / github.com/chain/Core / checkError

Method checkError

sdk/java/src/main/java/com/chain/http/Client.java:483–507  ·  view source on GitHub ↗
(Response response)

Source from the content-addressed store, hash-verified

481 }
482
483 private Response checkError(Response response) throws ChainException {
484 String rid = response.headers().get("Chain-Request-ID");
485 if (rid == null || rid.length() == 0) {
486 // Header field Chain-Request-ID is set by the backend
487 // API server. If this field is set, then we can expect
488 // the body to be well-formed JSON. If it's not set,
489 // then we are probably talking to a gateway or proxy.
490 throw new ConnectivityException(response);
491 }
492
493 if ((response.code() / 100) != 2) {
494 try {
495 APIException err =
496 Utils.serializer.fromJson(response.body().charStream(), APIException.class);
497 if (err.code != null) {
498 err.requestId = rid;
499 err.statusCode = response.code();
500 throw err;
501 }
502 } catch (IOException ex) {
503 throw new JSONException("Unable to read body. " + ex.getMessage(), rid);
504 }
505 }
506 return response;
507 }
508
509 private void nextURL(int failedIndex) {
510 if (this.urls.size() == 1) {

Callers 1

postMethod · 0.95

Calls 4

fromJsonMethod · 0.80
codeMethod · 0.65
getMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected