Maintenance: improve error wrapping

This commit is contained in:
Quentin McGaw (desktop)
2021-05-30 16:14:08 +00:00
parent be22c8547f
commit 876563c492
19 changed files with 96 additions and 41 deletions

View File

@@ -2,11 +2,16 @@ package healthcheck
import (
"context"
"errors"
"fmt"
"io"
"net/http"
)
var (
ErrHTTPStatusNotOK = errors.New("HTTP response status is not OK")
)
type Checker interface {
Check(ctx context.Context, url string) error
}
@@ -38,5 +43,5 @@ func (h *checker) Check(ctx context.Context, url string) error {
if err != nil {
return err
}
return fmt.Errorf("%s: %s", response.Status, string(b))
return fmt.Errorf("%w: %s: %s", ErrHTTPStatusNotOK, response.Status, string(b))
}