From 00f5982e9755cf6637321ef97d51a002a5f0a166 Mon Sep 17 00:00:00 2001 From: shugo Date: Thu, 2 Jul 2009 02:19:37 +0000 Subject: [PATCH] * lib/net/imap.rb: added response to Net::IMAP::ResponseError. a patch from Eric Hodel in [ruby-core:24111]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ lib/net/imap.rb | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa15cc368a..42c3fece24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Jul 2 11:16:25 2009 Shugo Maeda + + * lib/net/imap.rb: added response to Net::IMAP::ResponseError. + a patch from Eric Hodel in [ruby-core:24111]. + Thu Jul 2 08:04:39 2009 Nobuyoshi Nakada * time.c (num_exact): rb_check_to_integer() can deal with both of diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 161e7ac32a..e67c294464 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -947,7 +947,7 @@ module Net @greeting = get_response if @greeting.name == "BYE" @sock.close - raise ByeResponseError, @greeting.raw_data + raise ByeResponseError, @greeting end @client_thread = Thread.current @@ -993,7 +993,7 @@ module Net end if resp.name == "BYE" && @logout_command_tag.nil? @sock.close - @exception = ByeResponseError.new(resp.raw_data) + @exception = ByeResponseError.new(resp) break end when ContinuationRequest @@ -1025,9 +1025,9 @@ module Net resp = @tagged_responses.delete(tag) case resp.name when /\A(?:NO)\z/ni - raise NoResponseError, resp.data.text + raise NoResponseError, resp when /\A(?:BAD)\z/ni - raise BadResponseError, resp.data.text + raise BadResponseError, resp else return resp end @@ -3328,6 +3328,16 @@ module Net # Superclass of all errors used to encapsulate "fail" responses # from the server. class ResponseError < Error + + # The response that caused this error + attr_accessor :response + + def initialize(response) + @response = response + + super @response.data.text + end + end # Error raised upon a "NO" response from the server, indicating