-
Notifications
You must be signed in to change notification settings - Fork 54
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
refactor(probeservices): use better naming #1628
Conversation
// ErrUnsupportedEndpoint indicates that we don't support this endpoint type. | ||
ErrUnsupportedEndpoint = errors.New("probe services: unsupported endpoint type") | ||
// ErrUnsupportedServiceType indicates that we don't support this service type. | ||
ErrUnsupportedServiceType = errors.New("probe services: unsupported service type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally do not change error strings. However, this error string is for a very uncommon case, because the service type should always be supported and so it's fine to modify it for consistency.
@@ -384,7 +386,7 @@ func TestOpenReportNewClientFailure(t *testing.T) { | |||
Type: "antani", | |||
} | |||
err = exp.OpenReportContext(context.Background()) | |||
if err.Error() != "probe services: unsupported endpoint type" { | |||
if !errors.Is(err, probeservices.ErrUnsupportedServiceType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I upgraded this line to use errors.Is
which is the idiomatic way of checking after errors.Is
was added to Go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Calling the endpoint base URL (e.g.,
https://www.example.com/
) "endpoint" could cause confusion because usually an API endpoint is something likehttps://www.example.com/api/v1/check-in
. To obviate this semantic issue, this diff attempts to avoid calling base URLs as endpoint throughout the tree.I am going to account this work as part of ooni/backend#754 because this is one of the possibly issues on which we can account this work. The original conversation with @ainghazal, which prodded me to make these changes, was related to his feedback after implementing #1625.