Interface ResponseFunction

    • Method Detail

      • emptyIfNotFound

        static EmptyResponseTransformer emptyIfNotFound()
        Transform every HTTP 404 status code into an empty response into an empty sequence, effectively suppressing the ClientException that would be forwarded otherwise. See emptyIfNotFound(RouteMatcher) for an override that supports applying the transformation to a subset of requests.
        Returns:
        a ResponseFunction that transforms any HTTP 404 error into an empty sequence
      • emptyOnErrorStatus

        static EmptyResponseTransformer emptyOnErrorStatus​(RouteMatcher routeMatcher,
                                                           Integer... codes)
        Transforms the given error status codes caused by requests matching the given RouteMatcher, effectively suppressing the ClientException that would be forwarded otherwise.

        Only a subset of HTTP status codes is supported, like all the ones from 400 and 500 series, except for the 429 (Too Many Requests) error that is handled upstream.

        Parameters:
        routeMatcher - the RouteMatcher determining whether to match a particular request
        codes - the list of HTTP status codes to match when applying this transformation
        Returns:
        a ResponseFunction that transforms matching requests and response statuses into an empty sequence
      • retryOnceOnErrorStatus

        static RetryingTransformer retryOnceOnErrorStatus​(Integer... codes)
        Applies a retry strategy to retry once with a fixed backoff of 1 second to the given error status codes caused by any request, effectively suppressing the ClientException that would be forwarded otherwise.

        Only a subset of HTTP status codes is supported, like all the ones from 400 and 500 series, except for the 429 (Too Many Requests) error that is handled upstream.

        Please note that if you specify error codes 502, 503 or 504 you will replace a built-in retry factory that handles Discord service errors using an exponential backoff with jitter strategy.

        Parameters:
        codes - the list of HTTP status codes to match when applying this transformation
        Returns:
        a ResponseFunction that transforms matching response statuses into sequence that retries the request once after waiting 1 second.
      • retryOnceOnErrorStatus

        static RetryingTransformer retryOnceOnErrorStatus​(RouteMatcher routeMatcher,
                                                          Integer... codes)
        Applies a retry strategy to retry once with a fixed backoff of 1 second to the given error status codes caused by requests matching the given RouteMatcher, effectively suppressing the ClientException that would be forwarded otherwise.

        Only a subset of HTTP status codes is supported, like all the ones from 400 and 500 series, except for the 429 (Too Many Requests) error that is handled upstream.

        Please note that if you specify error codes 502, 503 or 504 you will replace a built-in retry factory that handles Discord service errors using an exponential backoff with jitter strategy.

        Parameters:
        routeMatcher - the RouteMatcher determining whether to match a particular request
        codes - the list of HTTP status codes to match when applying this transformation
        Returns:
        a ResponseFunction that transforms matching response statuses into sequence that retries the request once after waiting 1 second.
      • retryWhen

        static RetryingTransformer retryWhen​(RouteMatcher routeMatcher,
                                             Retry<?> retry)
        Applies a custom retry strategy to the requests matching the given RouteMatcher, effectively suppressing the ClientException that would be forwarded otherwise.

        Care must be taken when applying this transformation while using a long running retry factory, as it may effectively block further requests on the same rate limiting bucket.

        Parameters:
        routeMatcher - the RouteMatcher determining whether to match a particular request
        retry - the Retry factory to install while applying this transformation
        Returns:
        a ResponseFunction that transforms matching response statuses into sequence that retries the request once after waiting 1 second.