Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return concrete error type #3360

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions receiver/scrapererror/partialscrapeerror.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ package scrapererror

import "errors"

// PartialScrapeError can be used to signalize that a subset of metrics were failed
// to be scraped
// PartialScrapeError is an error to represent
// that a subset of metrics were failed to be scraped.
type PartialScrapeError struct {
error
Failed int
}

// NewPartialScrapeError creates PartialScrapeError for failed metrics.
// Use this error type only when a subset of data was failed to be scraped.
func NewPartialScrapeError(err error, failed int) error {
func NewPartialScrapeError(err error, failed int) PartialScrapeError {
return PartialScrapeError{
error: err,
Failed: failed,
Expand Down
2 changes: 1 addition & 1 deletion receiver/scrapererror/partialscrapeerror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestPartialScrapeError(t *testing.T) {
err := fmt.Errorf("some error")
partialErr := NewPartialScrapeError(err, failed)
assert.Equal(t, err.Error(), partialErr.Error())
assert.Equal(t, failed, partialErr.(PartialScrapeError).Failed)
assert.Equal(t, failed, partialErr.Failed)
}

func TestIsPartialScrapeError(t *testing.T) {
Expand Down