Skip to content

Use an error constant for "nil client" errors - #90

Merged
arbll merged 4 commits into
DataDog:masterfrom
asf-stripe:constant-error-on-nil
May 29, 2019
Merged

Use an error constant for "nil client" errors#90
arbll merged 4 commits into
DataDog:masterfrom
asf-stripe:constant-error-on-nil

Conversation

@asf-stripe

Copy link
Copy Markdown
Contributor

This PR adjusts the error behavior for nil clients to be a bit more consistent:

  • Returns an error that can be checked in tests when a nil client is used (from the freshly-allocated errors in Don't ignore nil clients #65)
  • Adjusts the error message:
    • bring it in line with go error conventions: No starting capital letter
    • mention that it's the statsd client that is nil

As mentioned in #65, this is affecting us in stripe/veneur#722; hope you all agree that this change will work.

This should allow tests and other code that relied on some
predictable behavior on nil client usage to still receive that
behavior: Instead of `nil`, we just return ErrNoClient now.

@arbll arbll left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those changes look perfectly reasonable to me. Just a small nitpick and we should be good to merge. Sorry for the breaking change, I didn't realize this could be used as a feature. Thanks for the PR!

Comment thread statsd/statsd_test.go
* Incr, Decr
* Timing, TimeInMilliseconds
By using assertNotPanics in the test case, we can assert that it
doesn't panic just as well, and it doesn't require maintaining the
same list of function calls in two tests.
@asf-stripe

Copy link
Copy Markdown
Contributor Author

Updated! PTAL, @arbll (:

@arbll arbll left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@arbll
arbll merged commit f6e7675 into DataDog:master May 29, 2019
@asf-stripe
asf-stripe deleted the constant-error-on-nil branch May 29, 2019 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants