Sha256: 23389ba773989e55ae1d7ee646eb60bec65454aa45a7393f29e8aaac6eea64c1

Contents?: true

Size: 1021 Bytes

Versions: 39

Compression:

Stored size: 1021 Bytes

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://github.com/jnunemaker/flipper/tree/master/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),
      }.freeze
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
flipper-api-0.16.1 lib/flipper/api/error_response.rb
flipper-api-0.16.0 lib/flipper/api/error_response.rb
flipper-api-0.15.0 lib/flipper/api/error_response.rb
flipper-api-0.14.0 lib/flipper/api/error_response.rb
flipper-api-0.13.0 lib/flipper/api/error_response.rb
flipper-api-0.13.0.beta1 lib/flipper/api/error_response.rb
flipper-api-0.12.2 lib/flipper/api/error_response.rb
flipper-api-0.12.1 lib/flipper/api/error_response.rb
flipper-api-0.12.0 lib/flipper/api/error_response.rb
flipper-api-0.11.0 lib/flipper/api/error_response.rb
flipper-api-0.11.0.rc1 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta9 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta8 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta7 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta6 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta5 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta4 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta3 lib/flipper/api/error_response.rb
flipper-api-0.11.0.beta1 lib/flipper/api/error_response.rb