diff --git a/app/models/incoming_email.rb b/app/models/incoming_email.rb index 97427699d92..2b33700a66d 100644 --- a/app/models/incoming_email.rb +++ b/app/models/incoming_email.rb @@ -3,7 +3,7 @@ class IncomingEmail < ActiveRecord::Base belongs_to :topic belongs_to :post - scope :errored, -> { where("NOT is_bounce AND LENGTH(COALESCE(error,'')) > 0") } + scope :errored, -> { where("NOT is_bounce AND error IS NOT NULL") } end # == Schema Information diff --git a/lib/email/receiver.rb b/lib/email/receiver.rb index 94a8dd77b38..245321a4468 100644 --- a/lib/email/receiver.rb +++ b/lib/email/receiver.rb @@ -49,7 +49,9 @@ module Email @incoming_email = create_incoming_email process_internal rescue => e - @incoming_email.update_columns(error: e.to_s) if @incoming_email + error = e.to_s + error = e.class.name if error.blank? + @incoming_email.update_columns(error: error) if @incoming_email raise end end diff --git a/spec/components/email/receiver_spec.rb b/spec/components/email/receiver_spec.rb index a7911a44465..28603db1a03 100644 --- a/spec/components/email/receiver_spec.rb +++ b/spec/components/email/receiver_spec.rb @@ -69,6 +69,12 @@ describe Email::Receiver do expect(IncomingEmail.last.is_bounce).to eq(true) end + it "logs a blank error" do + Email::Receiver.any_instance.stubs(:process_internal).raises(RuntimeError, "") + process(:existing_user) rescue RuntimeError + expect(IncomingEmail.last.error).to eq("RuntimeError") + end + context "bounces to VERP" do let(:bounce_key) { "14b08c855160d67f2e0c2f8ef36e251e" }