Sha256: 3866ef8b0e94ef13ba87ee93e21998f40b7cea0dd0b2806e3a3884fc6d275f2d

Contents?: true

Size: 1.11 KB

Versions: 10

Compression:

Stored size: 1.11 KB

Contents

module Flipper
  module Api
    module ErrorResponse
      class Error
        attr_reader :http_status

        def initialize(code, message, http_status)
          @code = code
          @message = message
          @more_info =
            'https://flippercloud.io/docs/api#error-code-reference'
          @http_status = http_status
        end

        def as_json
          {
            code: @code,
            message: @message,
            more_info: @more_info,
          }
        end
      end

      ERRORS = {
        feature_not_found: Error.new(1, 'Feature not found.', 404),
        group_not_registered: Error.new(2, 'Group not registered.', 404),
        percentage_invalid: Error.new(3, 'Percentage must be a positive number less than or equal to 100.', 422),
        flipper_id_invalid: Error.new(4, 'Required parameter flipper_id is missing.', 422),
        name_invalid: Error.new(5, 'Required parameter name is missing.', 422),
        import_invalid: Error.new(6, 'Import invalid.', 422),
        expression_invalid: Error.new(7, 'The provided expression was not valid.', 422),
      }.freeze
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
flipper-api-1.3.2 lib/flipper/api/error_response.rb
flipper-api-1.3.1 lib/flipper/api/error_response.rb
flipper-api-1.3.0 lib/flipper/api/error_response.rb
flipper-api-1.3.0.pre lib/flipper/api/error_response.rb
flipper-api-1.2.2 lib/flipper/api/error_response.rb
flipper-api-1.2.1 lib/flipper/api/error_response.rb
flipper-api-1.2.0 lib/flipper/api/error_response.rb
flipper-api-1.1.2 lib/flipper/api/error_response.rb
flipper-api-1.1.1 lib/flipper/api/error_response.rb
flipper-api-1.1.0 lib/flipper/api/error_response.rb