public Exception decode()

in src/main/java/com/epam/digital/data/platform/reportexporter/config/feign/FeignErrorDecoder.java [33:54]


  public Exception decode(String methodKey, Response response) {
    var status = HttpStatus.valueOf(response.status());
    var exception = defaultErrorDecoder.decode(methodKey, response);

    if (status.equals(HttpStatus.NOT_FOUND)) {
      throw new NotFoundException("Redash object not found");
    }

    if (exception instanceof RetryableException) {
      return exception;
    }

    log.error("Error during call to Redash, status code {}, response body: {}",
        response.status(), response.body());

    if (status.is5xxServerError()) {
      return new RetryableException(status.value(), "Redash server error",
          response.request().httpMethod(), null, response.request());
    }

    return exception;
  }