From 858e600f63ab9c1c318f3f5fadfee9bc93caca50 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..81d282075 100644 --- a/client_options.go +++ b/client_options.go @@ -118,6 +118,14 @@ func WithResponseLogHook(hook retryablehttp.ResponseLogHook) 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 + } +} + // WithoutRetries disables the default retry logic. func WithoutRetries() ClientOptionFunc { return func(c *Client) error {