java.lang.Object
es.kukenan.smartfi.microservice.contracts.service.backoffice.api.RestResponseErrorHandler
All Implemented Interfaces:
org.springframework.web.client.ResponseErrorHandler

public class RestResponseErrorHandler extends Object implements org.springframework.web.client.ResponseErrorHandler
Rest response error handler.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final String
    Backoffice name.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    private String
    extractErrorResponse(org.springframework.http.client.ClientHttpResponse response)
    Try to create a string from the error response with the only purpose to be logged.
    void
    handleError(org.springframework.http.client.ClientHttpResponse response)
    Handle an error response, that is, throw the proper KukenanWalletException.
    boolean
    hasError(org.springframework.http.client.ClientHttpResponse response)
     
    protected void
    throwUnexpectedException(String errorMsg, String errorResponseBody)
    Throws the specific unexpected exception from the error response.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.web.client.ResponseErrorHandler

    handleError
  • Field Details

    • backoffice

      private final String backoffice
      Backoffice name.
  • Constructor Details

    • RestResponseErrorHandler

      public RestResponseErrorHandler(String backoffice)
      Constructor.
      Parameters:
      backoffice - backoffice name.
  • Method Details

    • hasError

      public boolean hasError(org.springframework.http.client.ClientHttpResponse response) throws IOException
      Specified by:
      hasError in interface org.springframework.web.client.ResponseErrorHandler
      Throws:
      IOException
    • handleError

      public void handleError(org.springframework.http.client.ClientHttpResponse response)
      Handle an error response, that is, throw the proper KukenanWalletException.
      Specified by:
      handleError in interface org.springframework.web.client.ResponseErrorHandler
      Parameters:
      response - error response.
    • throwUnexpectedException

      protected void throwUnexpectedException(String errorMsg, String errorResponseBody)
      Throws the specific unexpected exception from the error response.
      Parameters:
      errorMsg - error message.
      errorResponseBody - error response body.
    • extractErrorResponse

      private String extractErrorResponse(org.springframework.http.client.ClientHttpResponse response)
      Try to create a string from the error response with the only purpose to be logged.
      Parameters:
      response - ClientHttpResponse.
      Returns:
      a string from the error response.