File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -335,6 +335,7 @@ defmodule Sentry do
335335 Client . send_event ( event , opts )
336336
337337 ! Config . dsn ( ) ->
338+ _opts = Client . validate_options! ( opts )
338339 :ignored
339340
340341 in cluded_envs == :all or to_string ( Config . environment_name ( ) ) in included_envs ->
Original file line number Diff line number Diff line change @@ -116,7 +116,7 @@ defmodule Sentry.Client do
116116 | :unsampled
117117 | :excluded
118118 def send_event ( % Event { } = event , opts ) when is_list ( opts ) do
119- opts = NimbleOptions . validate !( opts , @ send_event_opts_schema )
119+ opts = validate_options !( opts )
120120
121121 result_type = Keyword . get_lazy ( opts , :result , & Config . send_result / 0 )
122122 sample_rate = Keyword . get_lazy ( opts , :sample_rate , & Config . sample_rate / 0 )
@@ -160,6 +160,11 @@ defmodule Sentry.Client do
160160 end
161161 end
162162
163+ @ spec validate_options! ( keyword ( ) ) :: keyword ( )
164+ def validate_options! ( opts ) when is_list ( opts ) do
165+ NimbleOptions . validate! ( opts , @ send_event_opts_schema )
166+ end
167+
163168 defp sample_event ( sample_rate ) do
164169 cond do
165170 sample_rate == 1 -> :ok
Original file line number Diff line number Diff line change @@ -119,6 +119,16 @@ defmodule SentryTest do
119119 assert logged_count == 2
120120 end
121121
122+ test "raises error with validate_and_ignore/1 in dev mode if opts passed are invalid " do
123+ put_test_config ( dsn: nil , test_mode: false )
124+
125+ assert_raise NimbleOptions.ValidationError , fn ->
126+ Sentry.Client . validate_options! ( client: [ bad_key: :nada ] )
127+ end
128+
129+ assert [ client: :hackney ] = Sentry.Client . validate_options! ( client: :hackney )
130+ end
131+
122132 test "does not send events if :dsn is not configured or nil (if not in test mode)" do
123133 put_test_config ( dsn: nil , test_mode: false )
124134 event = Sentry.Event . transform_exception ( % RuntimeError { message: "oops" } , [ ] )
You can’t perform that action at this time.
0 commit comments