Skip to content

Commit ed203c6

Browse files
authored
fix(go): better network error (#3943)
1 parent 4f5b162 commit ed203c6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

clients/algoliasearch-client-go/algolia/errs/no_more_host_to_try_err.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package errs
22

3+
import (
4+
"errors"
5+
"fmt"
6+
)
7+
38
var ErrNoMoreHostToTry = NewNoMoreHostToTryError()
49

510
type NoMoreHostToTryError struct {
@@ -17,5 +22,8 @@ func (e *NoMoreHostToTryError) IntermediateNetworkErrors() []error {
1722
}
1823

1924
func (e *NoMoreHostToTryError) Error() string {
25+
if len(e.intermediateNetworkErrors) > 0 {
26+
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()
27+
}
2028
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."
2129
}

0 commit comments

Comments
 (0)