From 00f5982e9755cf6637321ef97d51a002a5f0a166 Mon Sep 17 00:00:00 2001 From: shugo Date: Thu, 2 Jul 2009 02:19:37 +0000 Subject: * 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 --- lib/net/imap.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lib/net') 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 -- cgit v1.2.3