From db9dda5722c485d85e8e3704d6a785525f2aa944 Mon Sep 17 00:00:00 2001 From: Tikhon Slasten Date: Fri, 9 Dec 2022 12:48:33 +1000 Subject: [PATCH] Add WithErrorHandler client option --- client_options.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client_options.go b/client_options.go index d2434b5b1..4774ed32d 100644 --- a/client_options.go +++ b/client_options.go @@ -94,6 +94,14 @@ func WithCustomRetryWaitMinMax(waitMin, waitMax time.Duration) ClientOptionFunc } } +// WithErrorHandler can be used to configure a custom error handler. +func WithErrorHandler(handler retryablehttp.ErrorHandler) ClientOptionFunc { + return func(c *Client) error { + c.client.ErrorHandler = handler + return nil + } +} + // WithHTTPClient can be used to configure a custom HTTP client. func WithHTTPClient(httpClient *http.Client) ClientOptionFunc { return func(c *Client) error {