[Groonga-commit] droonga/fluent-plugin-droonga at 6801cdc [master] Define the error for "unknown source" as a regular command error

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Dec 26 18:28:47 JST 2013


YUKI Hiroshi	2013-12-26 18:28:47 +0900 (Thu, 26 Dec 2013)

  New Revision: 6801cdc26785dcecb7fa7c5cf9c3e65c5e866cd5
  https://github.com/droonga/fluent-plugin-droonga/commit/6801cdc26785dcecb7fa7c5cf9c3e65c5e866cd5

  Message:
    Define the error for "unknown source" as a regular command error

  Modified files:
    lib/droonga/searcher.rb
    test/unit/plugin/handler/test_search.rb

  Modified: lib/droonga/searcher.rb (+6 -9)
===================================================================
--- lib/droonga/searcher.rb    2013-12-26 17:59:14 +0900 (c0de633)
+++ lib/droonga/searcher.rb    2013-12-26 18:28:47 +0900 (c6004fe)
@@ -21,14 +21,11 @@ require "groonga"
 
 module Droonga
   class Searcher
-    class Error < StandardError
-    end
-
-    class UndefinedSourceError < Error
-      attr_reader :name
-      def initialize(name)
-        @name = name
-        super("undefined source was used: <#{name}>")
+    class UnknownSource < BadRequest
+      def initialize(source, queries)
+        super("The source #{source.inspect} does not exist. " +
+                "It must be a name of an existing table or another query.",
+              queries)
       end
     end
 
@@ -81,7 +78,7 @@ module Droonga
         elsif @context[name]
           results[name] = @context[name]
         else
-          raise UndefinedSourceError.new(name)
+          raise UnknownSource.new(name, queries)
         end
       end
       $log.trace("#{log_tag}: process_queries: done")

  Modified: test/unit/plugin/handler/test_search.rb (+1 -1)
===================================================================
--- test/unit/plugin/handler/test_search.rb    2013-12-26 17:59:14 +0900 (c3384c5)
+++ test/unit/plugin/handler/test_search.rb    2013-12-26 18:28:47 +0900 (24810f0)
@@ -142,7 +142,7 @@ class SearchHandlerTest < Test::Unit::TestCase
 
     class SourceTest < self
       def test_non_existent
-        assert_raise(Droonga::Searcher::UndefinedSourceError) do
+        assert_raise(Droonga::Searcher::UnknownSource) do
           search({
                    "queries" => {
                      "non-existent-result" => {
-------------- next part --------------
HTML����������������������������...
Descargar 



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