[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-devel] [PATCH] Catch errors while saving a message to disk for editing



On Sat, Jul 2, 2011 at 18:06, Sascha Silbe <sascha-pgp@silbe.org> wrote:

>  lib/sup/modes/edit-message-mode.rb |   24 +++++++++++++++++-------
>  1 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/lib/sup/modes/edit-message-mode.rb b/lib/sup/modes/edit-message-mode.rb
> index 5ed7833..256e314 100644
> --- a/lib/sup/modes/edit-message-mode.rb
> +++ b/lib/sup/modes/edit-message-mode.rb
> @@ -172,12 +172,21 @@ def edit_to; edit_field "To" end
>   def edit_cc; edit_field "Cc" end
>   def edit_subject; edit_field "Subject" end
>
> -  def edit_message
> -    @file = Tempfile.new "sup.#{self.class.name.gsub(/.*::/, '').camel_to_hyphy}"
> +  def save_message_to_file

Didn't you mean 'write_message_to_file' here instead?

> +    @file = Tempfile.new ["sup.#{self.class.name.gsub(/.*::/, '').camel_to_hyphy}", ".eml"]
>     @file.puts format_headers(@header - NON_EDITABLE_HEADERS).first
>     @file.puts
>     @file.puts @body.join("\n")
>     @file.close
> +  end
> +
> +  def edit_message
> +    begin
> +      write_message_to_file
> +    rescue SystemCallError => e
> +      BufferManager.flash "Can't save message to file: #{e.message}"
> +      return
> +    end
>
>     editor = $config[:editor] || ENV['EDITOR'] || "/usr/bin/vi"
>
[snip]
_______________________________________________
Sup-devel mailing list
Sup-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-devel