[Groonga-commit] droonga/drntest at 85508e4 [master] Shorten message of InvalidValue error

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Dec 13 14:16:30 JST 2014


Kouhei Sutou	2014-12-13 14:16:30 +0900 (Sat, 13 Dec 2014)

  New Revision: 85508e457c59e31c7157d1a27cb5c52334e7d8f6
  https://github.com/droonga/drntest/commit/85508e457c59e31c7157d1a27cb5c52334e7d8f6

  Message:
    Shorten message of InvalidValue error

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

  Modified: lib/drntest/response-normalizer.rb (+13 -0)
===================================================================
--- lib/drntest/response-normalizer.rb    2014-11-18 11:41:47 +0900 (b852ff7)
+++ lib/drntest/response-normalizer.rb    2014-12-13 14:16:30 +0900 (165de17)
@@ -73,12 +73,25 @@ module Drntest
     def normalize_errors(errors)
       normalized_errors = {}
       error_details = errors.values
+      error_details.each do |error_detail|
+        normalize_error_detail!(error_detail)
+      end
       errors.keys.each_with_index do |source, index|
         normalized_errors["sources#{index}"] = error_details[index]
       end
       normalized_errors
     end
 
+    def normalize_error_detail!(error_detail)
+      case error_detail["body"]["name"]
+      when "InvalidValue"
+        message = error_detail["body"]["message"]
+        message = message.lines.first.chomp
+        message = message.gsub(/\#<(Groonga::[a-zA-Z]+) .*>\z/, "\#<\\1 ...>")
+        error_detail["body"]["message"] = message
+      end
+    end
+
     def normalize_groonga_command_response!(response)
       normalize_groonga_command_header!(response[0])
       normalize_groonga_command_body!(response[1..-1])
-------------- next part --------------
HTML����������������������������...
Télécharger 



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