Sha256: 29ce95edd19858bfc352d4c8f3188af49e2e5aa172452e794a3a91dba49ecbbf

Contents?: true

Size: 1.94 KB

Versions: 234

Compression:

Stored size: 1.94 KB

Contents

#
# Fluentd
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#

module Fluent
  module Counter
    class BaseError < StandardError
      def to_hash
        { 'code' => code, 'message' => message }
      end

      def code
        raise NotImplementedError
      end
    end

    class InvalidParams < BaseError
      def code
        'invalid_params'
      end
    end

    class UnknownKey < BaseError
      def code
        'unknown_key'
      end
    end

    class ParseError < BaseError
      def code
        'parse_error'
      end
    end

    class InvalidRequest < BaseError
      def code
        'invalid_request'
      end
    end

    class MethodNotFound < BaseError
      def code
        'method_not_found'
      end
    end

    class InternalServerError < BaseError
      def code
        'internal_server_error'
      end
    end

    def raise_error(response)
      msg = response['message']
      case response['code']
      when 'invalid_params'
        raise InvalidParams.new(msg)
      when 'unknown_key'
        raise UnknownKey.new(msg)
      when 'parse_error'
        raise ParseError.new(msg)
      when 'invalid_request'
        raise InvalidRequest.new(msg)
      when 'method_not_found'
        raise MethodNotFound.new(msg)
      when 'internal_server_error'
        raise InternalServerError.new(msg)
      else
        raise "Unknown code: #{response['code']}"
      end
    end
    module_function :raise_error
  end
end

Version data entries

234 entries across 234 versions & 7 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/lib/fluent/counter/error.rb
fluentd-1.16.6-x86-mingw32 lib/fluent/counter/error.rb
fluentd-1.16.6-x64-mingw32 lib/fluent/counter/error.rb
fluentd-1.16.6-x64-mingw-ucrt lib/fluent/counter/error.rb
fluentd-1.16.6 lib/fluent/counter/error.rb
fluentd-1.17.1-x86-mingw32 lib/fluent/counter/error.rb
fluentd-1.17.1-x64-mingw32 lib/fluent/counter/error.rb
fluentd-1.17.1-x64-mingw-ucrt lib/fluent/counter/error.rb
fluentd-1.17.1 lib/fluent/counter/error.rb
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/lib/fluent/counter/error.rb
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/lib/fluent/counter/error.rb
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/fluentd-1.17.0-x64-mingw-ucrt/lib/fluent/counter/error.rb
fluentd-1.17.0-x86-mingw32 lib/fluent/counter/error.rb
fluentd-1.17.0-x64-mingw-ucrt lib/fluent/counter/error.rb
fluentd-1.17.0-x64-mingw32 lib/fluent/counter/error.rb
fluentd-1.17.0 lib/fluent/counter/error.rb
fluentd-1.16.5-x64-mingw-ucrt lib/fluent/counter/error.rb
fluentd-1.16.5-x86-mingw32 lib/fluent/counter/error.rb
fluentd-1.16.5-x64-mingw32 lib/fluent/counter/error.rb
fluentd-1.16.5 lib/fluent/counter/error.rb