File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,8 @@ defmodule Mix.Tasks.Sentry.SendTestEvent do
5353 case result do
5454 { :ok , id } ->
5555 Mix . shell . info "Test event sent! Event ID: #{ id } "
56+ :error ->
57+ Mix . shell . info "Error sending event!"
5658 :excluded ->
5759 Mix . shell . info "No test event was sent because the event was excluded by a filter"
5860 end
Original file line number Diff line number Diff line change @@ -139,8 +139,8 @@ defmodule Sentry.Client do
139139 error_header = :proplists . get_value ( "X-Sentry-Error" , headers , "" )
140140 log_api_error ( "#{ body } \n Received #{ status } from Sentry server: #{ error_header } " )
141141 :error
142- _ ->
143- log_api_error ( body )
142+ e ->
143+ log_api_error ( " #{ inspect ( e ) } \n #{ body } " )
144144 :error
145145 end
146146 end
Original file line number Diff line number Diff line change 11defmodule Mix.Tasks.Sentry.SendTestEventTest do
22 use ExUnit.Case
33 import ExUnit.CaptureIO
4+ import ExUnit.CaptureLog
45 import Sentry.TestEnvironmentHelper
56
67 test "prints if environment_name is not in included_environments" do
@@ -46,4 +47,29 @@ defmodule Mix.Tasks.Sentry.SendTestEventTest do
4647 Test event sent! Event ID: 340
4748 """
4849 end
50+
51+ test "handles :error when Sentry server is failing" do
52+ bypass = Bypass . open
53+ Bypass . expect bypass , fn conn ->
54+ { :ok , _body , conn } = Plug.Conn . read_body ( conn )
55+ Plug.Conn . resp ( conn , 500 , ~s< {"id": "340"}> )
56+ end
57+ modify_env ( :sentry , [ dsn: "http://public:secret@localhost:#{ bypass . port } /1" ] )
58+ assert capture_log ( fn ->
59+ assert capture_io ( fn ->
60+ Mix.Tasks.Sentry.SendTestEvent . run ( [ ] )
61+ end ) == """
62+ Client configuration:
63+ server: http://localhost:#{ bypass . port } /api/1/store/
64+ public_key: public
65+ secret_key: secret
66+ included_environments: [:test]
67+ current environment_name: :test
68+ hackney_opts: [recv_timeout: 50]
69+
70+ Sending test event...
71+ Error sending event!
72+ """
73+ end ) =~ "Failed to send Sentry event"
74+ end
4975end
You can’t perform that action at this time.
0 commit comments