File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,13 @@ def perform(location_id)
99 location = Location . find ( location_id )
1010 LocationPositionUpdater . call ( location )
1111 rescue LocationPositionUpdater ::NoResults => e
12- Sentry . capture_exception ( e , level : "warning" )
12+ if Settings . location_position_updater_job . capture_exception
13+ Sentry . capture_exception ( e , level : "warning" )
14+ else
15+ Rails . logger . warn (
16+ "Could not fetch position for: #{ location . name } (#{ location . id } )"
17+ )
18+ Rails . logger . warn ( e . backtrace . join ( "\n " ) )
19+ end
1320 end
1421end
Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ ordnance_survey:
6464 api_key : <%= Rails.application.credentials.ordnance_survey&.api_key %>
6565 secret_key : <%= Rails.application.credentials.ordnance_survey&.secret_key %>
6666
67+ location_position_updater_job :
68+ capture_exception : true
69+
6770# Set a value to override the default values set in config/initializers/devise.rb
6871devise :
6972 timeout_in_seconds :
Original file line number Diff line number Diff line change @@ -29,3 +29,6 @@ reporting_api:
2929
3030careplus :
3131 base_url : http://localhost:8080
32+
33+ location_position_updater_job :
34+ capture_exception : false
Original file line number Diff line number Diff line change @@ -26,3 +26,6 @@ splunk:
2626reporting_api :
2727 client_app :
2828 root_url : http://localhost:4101
29+
30+ location_position_updater_job :
31+ capture_exception : false
Original file line number Diff line number Diff line change 2020
2121careplus :
2222 base_url : <%= ENV.fetch("MOCK_CAREPLUS_URL", nil) %>
23+
24+ location_position_updater_job :
25+ capture_exception : false
Original file line number Diff line number Diff line change @@ -27,3 +27,6 @@ reporting_api:
2727
2828careplus :
2929 base_url : http://localhost:8080
30+
31+ location_position_updater_job :
32+ capture_exception : false
Original file line number Diff line number Diff line change 3939 allow ( LocationPositionUpdater ) . to receive ( :call ) . and_raise ( error )
4040 end
4141
42- it "captures the exception in Sentry at warning level" do
43- expect ( Sentry ) . to receive ( :capture_exception ) . with (
44- error ,
45- level : "warning"
46- )
47- perform
42+ context "when not capturing the exception" do
43+ it "doesn't capture the exception in Sentry" do
44+ expect ( Sentry ) . not_to receive ( :capture_exception )
45+ perform
46+ end
47+
48+ it "does not raise the error" do
49+ expect { perform } . not_to raise_error
50+ end
4851 end
4952
50- it "does not raise the error" do
51- expect { perform } . not_to raise_error
53+ context "when capturing the exception" do
54+ before do
55+ Settings . location_position_updater_job . capture_exception = true
56+ end
57+
58+ after { Settings . reload! }
59+
60+ it "captures the exception in Sentry at warning level" do
61+ expect ( Sentry ) . to receive ( :capture_exception ) . with (
62+ error ,
63+ level : "warning"
64+ )
65+ perform
66+ end
67+
68+ it "does not raise the error" do
69+ expect { perform } . not_to raise_error
70+ end
5271 end
5372 end
5473
You can’t perform that action at this time.
0 commit comments