[Groonga-commit] droonga/fluent-plugin-droonga at 2da7b05 [master] Raise custom error for syntax error of catalog.json

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Feb 12 12:00:41 JST 2014


YUKI Hiroshi	2014-02-12 12:00:41 +0900 (Wed, 12 Feb 2014)

  New Revision: 2da7b05e2244c2b19d5e86b11cdcd56bb0279f09
  https://github.com/droonga/fluent-plugin-droonga/commit/2da7b05e2244c2b19d5e86b11cdcd56bb0279f09

  Message:
    Raise custom error for syntax error of catalog.json

  Modified files:
    lib/droonga/catalog.rb
    lib/droonga/catalog_loader.rb

  Modified: lib/droonga/catalog.rb (+9 -0)
===================================================================
--- lib/droonga/catalog.rb    2014-02-09 13:55:55 +0900 (8d1e859)
+++ lib/droonga/catalog.rb    2014-02-12 12:00:41 +0900 (b9b2a69)
@@ -21,4 +21,13 @@ module Droonga
   class << self
     attr_accessor :catalog
   end
+
+  class InvalidCatalog < StandardError
+    attr_reader :message, :detail
+
+    def initialize(message, detail=nil)
+      @message = message
+      @detail = detail
+    end
+  end
 end

  Modified: lib/droonga/catalog_loader.rb (+2 -0)
===================================================================
--- lib/droonga/catalog_loader.rb    2014-02-09 13:55:55 +0900 (c0665d0)
+++ lib/droonga/catalog_loader.rb    2014-02-12 12:00:41 +0900 (fff57d9)
@@ -28,6 +28,8 @@ module Droonga
         JSON.parse(file.read)
       end
       Catalog::Version1.new(data, File.dirname(@path))
+    rescue JSON::ParserError => error
+      raise InvalidCatalog.new("Syntax error in #{@path}", error)
     end
   end
 end
-------------- next part --------------
HTML����������������������������...
Download 



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