[前][次][番号順一覧][スレッド一覧]

ruby-changes:12245

From: shugo <ko1@a...>
Date: Thu, 2 Jul 2009 11:20:10 +0900 (JST)
Subject: [ruby-changes:12245] Ruby:r23934 (trunk): * lib/net/imap.rb: added response to Net::IMAP::ResponseError.

shugo	2009-07-02 11:19:37 +0900 (Thu, 02 Jul 2009)

  New Revision: 23934

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23934

  Log:
    * lib/net/imap.rb: added response to Net::IMAP::ResponseError.
      a patch from Eric Hodel in [ruby-core:24111].

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/imap.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 23933)
+++ ChangeLog	(revision 23934)
@@ -1,3 +1,8 @@
+Thu Jul  2 11:16:25 2009  Shugo Maeda  <shugo@r...>
+
+	* 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  <nobu@r...>
 
 	* time.c (num_exact): rb_check_to_integer() can deal with both of
Index: lib/net/imap.rb
===================================================================
--- lib/net/imap.rb	(revision 23933)
+++ lib/net/imap.rb	(revision 23934)
@@ -947,7 +947,7 @@
       @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 @@
               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 @@
       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 @@
     # 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]