-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Validate options in dev mode #772
Conversation
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.
Left just a couple of comments but this is great.
lib/sentry.ex
Outdated
@@ -335,7 +335,7 @@ defmodule Sentry do | |||
Client.send_event(event, opts) | |||
|
|||
!Config.dsn() -> | |||
:ignored | |||
Client.validate_and_ignore(opts) |
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.
This is gonna make it harder to track the return value–I have to jump to another module. Maybe we can do
Client.validate_options!(opts)
:ignored
instead?
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.
Yes, good idea!
lib/sentry/client.ex
Outdated
@@ -160,6 +160,12 @@ defmodule Sentry.Client do | |||
end | |||
end | |||
|
|||
@spec validate_and_ignore(keyword()) :: :ignored | |||
def validate_and_ignore(opts) when is_list(opts) do |
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 can also re-use this function above where we call NimbleOptions.validate!
if we change it to return the options, like suggested in the other comment.
test/sentry_test.exs
Outdated
assert_raise(NimbleOptions.ValidationError, fn -> | ||
Sentry.Client.validate_and_ignore(client: [bad_key: :nada]) | ||
end) |
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.
Nit:
assert_raise(NimbleOptions.ValidationError, fn -> | |
Sentry.Client.validate_and_ignore(client: [bad_key: :nada]) | |
end) | |
assert_raise NimbleOptions.ValidationError, fn -> | |
Sentry.Client.validate_and_ignore(client: [bad_key: :nada]) | |
end |
test/sentry_test.exs
Outdated
Sentry.Client.validate_and_ignore(client: [bad_key: :nada]) | ||
end) | ||
|
||
assert :ignored == Sentry.Client.validate_and_ignore(client: :hackney) |
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.
Nit, but matches other tests:
assert :ignored == Sentry.Client.validate_and_ignore(client: :hackney) | |
assert :ignored = Sentry.Client.validate_and_ignore(client: :hackney) |
7653b87
to
01bf409
Compare
-validate all options passed to send_event even when in dev mode
-closes #766