diff --git a/.circleci/config.yml b/.circleci/config.yml index 58edd33..af400b3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 jobs: build: docker: - - image: alexfalkowski/go:1.23 + - image: alexfalkowski/go:1.3 - image: alexfalkowski/status:latest command: server environment: @@ -47,7 +47,7 @@ jobs: resource_class: large release: docker: - - image: alexfalkowski/release:3.1 + - image: alexfalkowski/release:3.4 working_directory: ~/go-health steps: - checkout diff --git a/server/server_test.go b/server/server_test.go index 8a32362..9958c16 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -273,7 +273,7 @@ func TestValidReadyChecker(t *testing.T) { time.Sleep(wait) Convey("Then I should have no error from the observer", func() { - So(ob.Error(), ShouldEqual, errNotReady) + So(ob.Error(), ShouldBeError) checker.Ready() diff --git a/subscriber/errors.go b/subscriber/errors.go index 7e4cf23..2b00291 100644 --- a/subscriber/errors.go +++ b/subscriber/errors.go @@ -1,27 +1,37 @@ package subscriber +import ( + "errors" + "fmt" +) + // Errors for observers. type Errors map[string]error -// Error the first error from map. +// Error the combined errors as one. func (e Errors) Error() error { - for _, err := range e { + errs := make([]error, len(e)) + i := 0 + + for k, err := range e { if err != nil { - return err + errs[i] = fmt.Errorf("%s: %w", k, err) } + + i++ } - return nil + return errors.Join(errs...) } // Errors is a copy. func (e Errors) Errors() Errors { - errors := make(Errors) + errs := make(Errors, len(e)) for k, v := range e { - errors[k] = v + errs[k] = v } - return errors + return errs } // Set the error at the name.