org.springframework.web.client

Class DefaultResponseErrorHandler

  • java.lang.Object
    • org.springframework.web.client.DefaultResponseErrorHandler
    • Constructor Detail

      • DefaultResponseErrorHandler

        public DefaultResponseErrorHandler()
    • Method Detail

      • hasError

        public boolean hasError(ClientHttpResponse response)
                         throws java.io.IOException
        Delegates to hasError(HttpStatus) with the response status code.
        Specified by:
        hasError in interface ResponseErrorHandler
        Parameters:
        response - the response to inspect
        Returns:
        true if the response has an error; false otherwise
        Throws:
        java.io.IOException - in case of I/O errors
      • hasError

        protected boolean hasError(HttpStatus statusCode)
        Template method called from hasError(ClientHttpResponse).

        The default implementation checks if the given status code is HttpStatus.Series#CLIENT_ERROR CLIENT_ERROR or HttpStatus.Series#SERVER_ERROR SERVER_ERROR. Can be overridden in subclasses.

        Parameters:
        statusCode - the HTTP status code
        Returns:
        true if the response has an error; false otherwise
      • getResponseBody

        protected byte[] getResponseBody(ClientHttpResponse response)
        Read the body of the given response (for inclusion in a status exception).
        Parameters:
        response - the response to inspect
        Returns:
        the response body as a byte array, or an empty byte array if the body could not be read
        Since:
        4.3.8
      • getCharset

        @Nullable
        protected java.nio.charset.Charset getCharset(ClientHttpResponse response)
        Determine the charset of the response (for inclusion in a status exception).
        Parameters:
        response - the response to inspect
        Returns:
        the associated charset, or null if none
        Since:
        4.3.8