[Groonga-commit] droonga/drndump at d44b188 [master] Add error response check

Back to archive index

Kouhei Sutou null+****@clear*****
Tue May 13 18:46:39 JST 2014


Kouhei Sutou	2014-05-13 18:46:39 +0900 (Tue, 13 May 2014)

  New Revision: d44b1882fbd6bdcdb6c0cad12a276027b30ae9fb
  https://github.com/droonga/drndump/commit/d44b1882fbd6bdcdb6c0cad12a276027b30ae9fb

  Message:
    Add error response check

  Modified files:
    bin/drndump

  Modified: bin/drndump (+10 -4)
===================================================================
--- bin/drndump    2014-05-02 18:47:35 +0900 (6a3cc93)
+++ bin/drndump    2014-05-13 18:46:39 +0900 (182f39e)
@@ -85,14 +85,20 @@ dump_message = {
 }
 client = Droonga::Client.new(options)
 
-error = nil
+error_message = nil
 client.subscribe(dump_message) do |message|
   case message
   when Droonga::Client::Error
     client.close
-    error = message
+    error_message = message.to_s
   else
     case message["type"]
+    when "dump.result"
+      if message["statusCode"] != 200
+        client.close
+        error = message["body"]
+        error_message = "#{error['name']}: #{error['message']}"
+      end
     when "dump.record"
       add_message = message.dup
       add_message.delete("inReplyTo")
@@ -105,7 +111,7 @@ client.subscribe(dump_message) do |message|
 end
 loop.run
 
-if error
-  $stderr.puts(error)
+if error_message
+  $stderr.puts(error_message)
   exit(false)
 end
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index