diff --git a/app/canary/dao/sentry.rb b/app/canary/dao/sentry.rb index eb9a1b0..a74d985 100644 --- a/app/canary/dao/sentry.rb +++ b/app/canary/dao/sentry.rb @@ -27,7 +27,7 @@ module CodeValet::Canary::DAO :expires_in => 10 * CACHE_SECONDS) do SentryApi.projects end - rescue *CodeValet::Canary::DAO::NET_ERRORS => e + rescue *CodeValet::Canary::DAO::NET_ERRORS, SentryApi::Error::Parsing => e @error = e return [] rescue StandardError => e @@ -46,7 +46,7 @@ module CodeValet::Canary::DAO :expires_in => CACHE_SECONDS) do SentryApi.project_issues(project_key) end - rescue *CodeValet::Canary::DAO::NET_ERRORS => e + rescue *CodeValet::Canary::DAO::NET_ERRORS, SentryApi::Error::Parsing => e @error = e return [] rescue StandardError => e @@ -67,7 +67,7 @@ module CodeValet::Canary::DAO :expires_in => 5 * CACHE_SECONDS) do SentryApi.issue(id) end - rescue *CodeValet::Canary::DAO::NET_ERRORS => e + rescue *CodeValet::Canary::DAO::NET_ERRORS, SentryApi::Error::Parsing => e @error = e return nil rescue StandardError => e @@ -81,7 +81,7 @@ module CodeValet::Canary::DAO :expires_in => CACHE_SECONDS) do SentryApi.issue_events(id) end - rescue *CodeValet::Canary::DAO::NET_ERRORS => e + rescue *CodeValet::Canary::DAO::NET_ERRORS, SentryApi::Error::Parsing => e @error = e return nil rescue StandardError => e diff --git a/spec/dao/sentry_spec.rb b/spec/dao/sentry_spec.rb index baad97b..b66cf95 100644 --- a/spec/dao/sentry_spec.rb +++ b/spec/dao/sentry_spec.rb @@ -64,6 +64,15 @@ describe CodeValet::Canary::DAO::Sentry do expect(dao).to be_errored end + # https://github.com/CodeValet/canary/issues/5 + it 'should gracefully handle Sentry API parsing errors' do + expect(SentryApi).to receive(:project_issues).and_raise(SentryApi::Error::Parsing) + expect(Raven).not_to receive(:capture_exception) + + expect(issues).to be_empty + expect(dao).to be_errored + end + it 'should gracefully handle and record unknown errors' do expect(SentryApi).to receive(:project_issues).and_raise(JSON::ParserError) expect(Raven).to receive(:capture_exception)