Class SpinnakerRetrofitErrorHandler
java.lang.Object
com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerRetrofitErrorHandler
- All Implemented Interfaces:
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.-
Field Summary
Fields inherited from interface retrofit.ErrorHandler
DEFAULT -
Method Summary
Modifier and TypeMethodDescriptionReturns an instance of aSpinnakerRetrofitErrorHandler.handleError(retrofit.RetrofitError e) Returns a more specificThrowabledepending on properties of the caughtRetrofitError.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.
-
Method Details
-
getInstance
Returns an instance of aSpinnakerRetrofitErrorHandler.- Returns:
- An instance of
SpinnakerRetrofitErrorHandler
-
handleError
Returns a more specificThrowabledepending on properties of the caughtRetrofitError.- Specified by:
handleErrorin interfaceretrofit.ErrorHandler- Parameters:
e- TheRetrofitErrorthrown by an invocation of theRestAdapter- Returns:
- A more informative
Throwable
-
handleError
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- TheRetrofitErrorthrown by an invocation of theRestAdaptermessageBuilder- 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:
-