[Groonga-commit] ranguba/groonga-client-model at c64390f [master] Use --output_errors

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Feb 3 18:29:24 JST 2017


Kouhei Sutou	2017-02-03 18:29:24 +0900 (Fri, 03 Feb 2017)

  New Revision: c64390f575d773e657164f02aa1ddb8274e3dc6a
  https://github.com/ranguba/groonga-client-model/commit/c64390f575d773e657164f02aa1ddb8274e3dc6a

  Message:
    Use --output_errors

  Modified files:
    groonga-client-model.gemspec
    lib/groonga_client_model/record.rb

  Modified: groonga-client-model.gemspec (+2 -2)
===================================================================
--- groonga-client-model.gemspec    2017-02-03 18:28:45 +0900 (eb36f00)
+++ groonga-client-model.gemspec    2017-02-03 18:29:24 +0900 (6a0f63b)
@@ -1,6 +1,6 @@
 # -*- ruby -*-
 #
-# Copyright (C) 2016  Kouhei Sutou <kou �� clear-code.com>
+# Copyright (C) 2016-2017  Kouhei Sutou <kou �� clear-code.com>
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -43,7 +43,7 @@ Gem::Specification.new do |spec|
   spec.files += Dir.glob("doc/text/*")
   spec.test_files += Dir.glob("test/**/*")
 
-  spec.add_runtime_dependency("groonga-client", ">= 0.3.7")
+  spec.add_runtime_dependency("groonga-client", ">= 0.4.1")
   spec.add_runtime_dependency("groonga-command-parser")
   spec.add_runtime_dependency("activemodel")
 

  Modified: lib/groonga_client_model/record.rb (+7 -1)
===================================================================
--- lib/groonga_client_model/record.rb    2017-02-03 18:28:45 +0900 (9e8f8f1)
+++ lib/groonga_client_model/record.rb    2017-02-03 18:29:24 +0900 (7229beb)
@@ -268,6 +268,7 @@ module GroongaClientModel
         response = client.load(table: table.name,
                                values: [value],
                                output_ids: "yes",
+                               output_errors: "yes",
                                command_version: "3")
         unless response.success?
           message = "Failed to save: "
@@ -275,7 +276,12 @@ module GroongaClientModel
           raise RecordNotSaved.new(message, self)
         end
         if response.n_loaded_records.zero?
-          message = "Failed to save: #{value.inspect}"
+          message = "Failed to save"
+          error = response.errors[0]
+          if error and !error.return_code.zero?
+            message << ": #{error.return_code}: #{error.message}: "
+          end
+          message << ": #{value.inspect}"
           raise RecordNotSaved.new(message, self)
         end
         if @new_record
-------------- next part --------------
HTML����������������������������...
Download 



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