YUKI Hiroshi
null+****@clear*****
Wed Feb 12 17:40:13 JST 2014
YUKI Hiroshi 2014-02-12 17:40:13 +0900 (Wed, 12 Feb 2014) New Revision: 7b27670a0a5c84c5a1b11cd5f46b3c8d737228ff https://github.com/droonga/fluent-plugin-droonga/commit/7b27670a0a5c84c5a1b11cd5f46b3c8d737228ff Message: Extract definitions of catalog validation errors Added files: lib/droonga/catalog/errors.rb Modified files: lib/droonga/catalog/base.rb Modified: lib/droonga/catalog/base.rb (+1 -53) =================================================================== --- lib/droonga/catalog/base.rb 2014-02-12 17:36:36 +0900 (5b2ee3e) +++ lib/droonga/catalog/base.rb 2014-02-12 17:40:13 +0900 (9ac3e96) @@ -17,62 +17,10 @@ require "digest/sha1" require "zlib" require "time" require "droonga/message_processing_error" +require "droonga/catalog/errors" module Droonga module Catalog - class ValidationError < Error - def initialize(message, path) - if path - super("Validation error in #{path}: #{message}") - else - super(message) - end - end - end - - class MissingRequiredParameter < ValidationError - def initialize(name, path) - super("You must specify \"#{name}\".", path) - end - end - - class MismatchedParameterType < ValidationError - def initialize(name, expected, actual, path) - super("\"#{name}\" must be a #{expected}, but a #{actual}.", path) - end - end - - class InvalidDate < ValidationError - def initialize(name, value, path) - super("\"#{name}\" must be a valid datetime. " + - "\"#{value}\" cannot be parsed as a datetime.", path) - end - end - - class NegativeNumber < ValidationError - def initialize(name, actual, path) - super("\"#{name}\" must be a positive number, but #{actual}.", path) - end - end - - class SmallerThanOne < ValidationError - def initialize(name, actual, path) - super("\"#{name}\" must be 1 or larger number, but #{actual}.", path) - end - end - - class UnknownFarm < ValidationError - def initialize(name, partition, path) - super("The partition #{partition} at \"#{name}\" seems to be bound to an unknown farm.", path) - end - end - - class UnsupportedValue < ValidationError - def initialize(name, value, path) - super("\"#{value}\" is not supported for \"#{name}\".", path) - end - end - class Base attr_reader :path, :base_path def initialize(data, path) Added: lib/droonga/catalog/errors.rb (+73 -0) 100644 =================================================================== --- /dev/null +++ lib/droonga/catalog/errors.rb 2014-02-12 17:40:13 +0900 (980555a) @@ -0,0 +1,73 @@ +# Copyright (C) 2014 Droonga Project +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License version 2.1 as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +require "droonga/error" + +module Droonga + module Catalog + class ValidationError < Error + def initialize(message, path) + if path + super("Validation error in #{path}: #{message}") + else + super(message) + end + end + end + + class MissingRequiredParameter < ValidationError + def initialize(name, path) + super("You must specify \"#{name}\".", path) + end + end + + class MismatchedParameterType < ValidationError + def initialize(name, expected, actual, path) + super("\"#{name}\" must be a #{expected}, but a #{actual}.", path) + end + end + + class InvalidDate < ValidationError + def initialize(name, value, path) + super("\"#{name}\" must be a valid datetime. " + + "\"#{value}\" cannot be parsed as a datetime.", path) + end + end + + class NegativeNumber < ValidationError + def initialize(name, actual, path) + super("\"#{name}\" must be a positive number, but #{actual}.", path) + end + end + + class SmallerThanOne < ValidationError + def initialize(name, actual, path) + super("\"#{name}\" must be 1 or larger number, but #{actual}.", path) + end + end + + class UnknownFarm < ValidationError + def initialize(name, partition, path) + super("The partition #{partition} at \"#{name}\" seems to be bound to an unknown farm.", path) + end + end + + class UnsupportedValue < ValidationError + def initialize(name, value, path) + super("\"#{value}\" is not supported for \"#{name}\".", path) + end + end + end +end -------------- next part -------------- HTML����������������������������...Download