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)
947 947
      @greeting = get_response
948 948
      if @greeting.name == "BYE"
949 949
        @sock.close
950
        raise ByeResponseError, @greeting.raw_data
950
        raise ByeResponseError, @greeting
951 951
      end
952 952

  
953 953
      @client_thread = Thread.current
......
993 993
              end
994 994
              if resp.name == "BYE" && @logout_command_tag.nil?
995 995
                @sock.close
996
                @exception = ByeResponseError.new(resp.raw_data)
996
                @exception = ByeResponseError.new(resp)
997 997
                break
998 998
              end
999 999
            when ContinuationRequest
......
1025 1025
      resp = @tagged_responses.delete(tag)
1026 1026
      case resp.name
1027 1027
      when /\A(?:NO)\z/ni
1028
        raise NoResponseError, resp.data.text
1028
        raise NoResponseError, resp
1029 1029
      when /\A(?:BAD)\z/ni
1030
        raise BadResponseError, resp.data.text
1030
        raise BadResponseError, resp
1031 1031
      else
1032 1032
        return resp
1033 1033
      end
......
3328 3328
    # Superclass of all errors used to encapsulate "fail" responses
3329 3329
    # from the server.
3330 3330
    class ResponseError < Error
3331

  
3332
      # The response that caused this error
3333
      attr_accessor :response
3334

  
3335
      def initialize(response)
3336
        @response = response
3337

  
3338
        super @response.data.text
3339
      end
3340

  
3331 3341
    end
3332 3342

  
3333 3343
    # Error raised upon a "NO" response from the server, indicating