Project

General

Profile

Bug #1713 ยป net_imap_response_in_error.diff

Net::IMAP::ResponseError patch to add response to raised exception - drbrain (Eric Hodel), 07/02/2009 07:29 AM

View differences:

lib/net/imap.rb (working copy)
@greeting = get_response
if @greeting.name == "BYE"
@sock.close
raise ByeResponseError, @greeting.raw_data
raise ByeResponseError, @greeting
end
@client_thread = Thread.current
......
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
......
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
......
# 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
    (1-1/1)