From 50bc53935b634978a2ff88b2a09b8e4eac567e23 Mon Sep 17 00:00:00 2001 From: Pierre Millot Date: Thu, 10 Oct 2024 14:09:43 +0200 Subject: [PATCH] fix(go): better network error --- .../algolia/errs/no_more_host_to_try_err.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/clients/algoliasearch-client-go/algolia/errs/no_more_host_to_try_err.go b/clients/algoliasearch-client-go/algolia/errs/no_more_host_to_try_err.go index 4c71ffa0b5..a01c5df9b5 100644 --- a/clients/algoliasearch-client-go/algolia/errs/no_more_host_to_try_err.go +++ b/clients/algoliasearch-client-go/algolia/errs/no_more_host_to_try_err.go @@ -1,5 +1,10 @@ package errs +import ( + "errors" + "fmt" +) + var ErrNoMoreHostToTry = NewNoMoreHostToTryError() type NoMoreHostToTryError struct { @@ -17,5 +22,8 @@ func (e *NoMoreHostToTryError) IntermediateNetworkErrors() []error { } func (e *NoMoreHostToTryError) Error() string { + if len(e.intermediateNetworkErrors) > 0 { + return fmt.Errorf("all hosts have been contacted unsuccessfully, it can either be a server or a network error or wrong appID/key credentials were used. %w", errors.Join(e.intermediateNetworkErrors...)).Error() + } return "all hosts have been contacted unsuccessfully, it can either be a server or a network error or wrong appID/key credentials were used. You can use 'ExposeIntermediateNetworkErrors: true' in the config to investigate." }