]> git.cworth.org Git - sup/commitdiff
better attachment error handling
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 7 Jul 2007 14:03:25 +0000 (14:03 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Sat, 7 Jul 2007 14:03:25 +0000 (14:03 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@478 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/modes/edit-message-mode.rb

index ae5416f27cb04d6c3a191e371e9127a261d4715a..e2c2b0657e4a3601b6c20b71c33e1996161f942b 100644 (file)
@@ -5,6 +5,8 @@ require 'rmail'
 
 module Redwood
 
+class SendmailCommandFailed < StandardError; end
+
 class EditMessageMode < LineCursorMode
   FORCE_HEADERS = %w(From To Cc Bcc Subject)
   MULTI_HEADERS = %w(To Cc Bcc)
@@ -161,15 +163,13 @@ protected
 
     begin
       IO.popen(acct.sendmail, "w") { |p| write_full_message_to p, date }
-    rescue SystemCallError
-    end
-    if $? == 0
+      raise SendmailCommandFailed, "Couldn't execute #{acct.sendmail}" unless $? == 0
       SentManager.write_sent_message(date, from_email) { |f| write_full_message_to f, date }
       BufferManager.kill_buffer buffer
       BufferManager.flash "Message sent!"
-    else
-      Redwood::log "Non-zero return value in running sendmail command for #{acct.longname}: #{acct.sendmail.inspect}"
-      BufferManager.flash "Problem sending mail. See log for details."
+    rescue SystemCallError, SendmailCommandFailed => e
+      Redwood::log "Problem sending mail: #{e.message}"
+      BufferManager.flash "Problem sending mail: #{e.message}"
     end
   end