mirror of https://github.com/codevalet/canary
Catch invalid responses from Sentry's API and treat them as expected errors
Fixes #5
This commit is contained in:
parent
6e1a1ef172
commit
3419d199e9
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue