[Groonga-commit] droonga/drntest at 60213d0 [master] Shorten message of InvalidValue error at top level

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Dec 13 14:22:51 JST 2014


Kouhei Sutou	2014-12-13 14:22:51 +0900 (Sat, 13 Dec 2014)

  New Revision: 60213d0a3ced330106184ac4ab440066a9060744
  https://github.com/droonga/drntest/commit/60213d0a3ced330106184ac4ab440066a9060744

  Message:
    Shorten message of InvalidValue error at top level

  Modified files:
    lib/drntest/response-normalizer.rb

  Modified: lib/drntest/response-normalizer.rb (+9 -5)
===================================================================
--- lib/drntest/response-normalizer.rb    2014-12-13 14:18:05 +0900 (165de17)
+++ lib/drntest/response-normalizer.rb    2014-12-13 14:22:51 +0900 (8b1d78f)
@@ -66,6 +66,10 @@ module Drntest
       in_reply_to = message["inReplyTo"]
       message["inReplyTo"] = normalized_in_reply_to if in_reply_to
 
+      if message["statusCode"] != 200
+        normalize_error_body!(message["body"])
+      end
+
       errors = message["errors"]
       message["errors"] = normalize_errors(errors) if errors
     end
@@ -74,7 +78,7 @@ module Drntest
       normalized_errors = {}
       error_details = errors.values
       error_details.each do |error_detail|
-        normalize_error_detail!(error_detail)
+        normalize_error_body!(error_detail["body"])
       end
       errors.keys.each_with_index do |source, index|
         normalized_errors["sources#{index}"] = error_details[index]
@@ -82,13 +86,13 @@ module Drntest
       normalized_errors
     end
 
-    def normalize_error_detail!(error_detail)
-      case error_detail["body"]["name"]
+    def normalize_error_body!(body)
+      case body["name"]
       when "InvalidValue"
-        message = error_detail["body"]["message"]
+        message = body["message"]
         message = message.lines.first.chomp
         message = message.gsub(/\#<(Groonga::[a-zA-Z]+) .*>\z/, "\#<\\1 ...>")
-        error_detail["body"]["message"] = message
+        body["message"] = message
       end
     end
 
-------------- next part --------------
HTML����������������������������...
下载 



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