From ae45baa18f0745bf7aa7d5985f8898ee9621c9a8 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Mon, 4 Sep 2017 12:46:44 -0700 Subject: [PATCH] Include OpenSSL::SSL::SSLError in the list of expected network related errors Fixes #2 --- app/canary/dao.rb | 2 ++ spec/dao/sentry_spec.rb | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/app/canary/dao.rb b/app/canary/dao.rb index 07b9087..ebf86b1 100644 --- a/app/canary/dao.rb +++ b/app/canary/dao.rb @@ -1,6 +1,7 @@ require 'concurrent/hash' require 'mini_cache' require 'net/http' +require 'openssl' module CodeValet module Canary @@ -15,6 +16,7 @@ module CodeValet Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, + OpenSSL::SSL::SSLError, ].freeze # Access the caching object diff --git a/spec/dao/sentry_spec.rb b/spec/dao/sentry_spec.rb index 038367b..aa3ab2e 100644 --- a/spec/dao/sentry_spec.rb +++ b/spec/dao/sentry_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' require 'json' +require 'openssl' require 'canary/dao/sentry' @@ -45,6 +46,15 @@ describe CodeValet::Canary::DAO::Sentry do expect(subject.projects).to eql(projects) end end + + # https://github.com/codevalet/canary/issues/2 + it 'should gracefully handle OpenSSL errors' do + expect(SentryApi).to receive(:projects).and_raise(OpenSSL::SSL::SSLError) + expect(Raven).not_to receive(:capture_exception) + + expect(subject.projects).to be_empty + expect(subject).to be_errored + end end it { should respond_to :issues_for }