Class SpinnakerRetrofitErrorHandler

java.lang.Object
com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler
All Implemented Interfaces:
retrofit.ErrorHandler

public final class SpinnakerRetrofitErrorHandler extends Object implements retrofit.ErrorHandler
An error handler to be registered with a RestAdapter. Allows clients to catch a SpinnakerServerException or something more specific (e.g. SpinnakerHttpException, or SpinnakerNetworkException) depending on the properties of the RetrofitError.
  • Method Details

    • getInstance

      public static SpinnakerRetrofitErrorHandler getInstance()
      Returns an instance of a SpinnakerRetrofitErrorHandler.
      Returns:
      An instance of SpinnakerRetrofitErrorHandler
    • handleError

      public Throwable handleError(retrofit.RetrofitError e)
      Returns a more specific Throwable depending on properties of the caught RetrofitError.
      Specified by:
      handleError in interface retrofit.ErrorHandler
      Parameters:
      e - The RetrofitError thrown by an invocation of the RestAdapter
      Returns:
      A more informative Throwable
    • handleError

      public Throwable handleError(retrofit.RetrofitError e, Function<Throwable,String> messageBuilder)
      For SpinnakerExceptions, return a new exception of the same type with the return value of handleError as its cause, with a message from messageBuilder. When handleError returns something other than SpinnakerException, this method is a no-op.
      Parameters:
      e - The RetrofitError thrown by an invocation of the RestAdapter
      messageBuilder - A function which takes in the throwable created by the handler, and outputs an error message string. The error message string is passed to a new exception which is then returned. This provides a mechanism to customize the string on the end throwable.
      Returns: