Sha256: 1792febfc15694622677610f0b569524df2dde41916ba14cece35ae395a5a045

Contents?: true

Size: 1.19 KB

Versions: 12

Compression:

Stored size: 1.19 KB

Contents

module JsonapiCompliable
  module Errors
    class BadFilter < StandardError; end
    class ValidationError < StandardError; end

    class UnsupportedPageSize < StandardError
      def initialize(size, max)
        @size, @max = size, max
      end

      def message
        "Requested page size #{@size} is greater than max supported size #{@max}"
      end
    end

    class InvalidInclude < StandardError
      def initialize(relationship, parent_resource)
        @relationship = relationship
        @parent_resource = parent_resource
      end

      def message
        "The requested included relationship \"#{@relationship}\" is not supported on resource \"#{@parent_resource}\""
      end
    end

    class StatNotFound < StandardError
      def initialize(attribute, calculation)
        @attribute = attribute
        @calculation = calculation
      end

      def message
        "No stat configured for calculation #{pretty(@calculation)} on attribute #{pretty(@attribute)}"
      end

      private

      def pretty(input)
        if input.is_a?(Symbol)
          ":#{input}"
        else
          "'#{input}'"
        end
      end
    end

    class RecordNotFound < StandardError
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
jsonapi_compliable-0.11.13 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.12 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.11 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.10 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.8 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.7 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.6 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.5 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.4 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.3 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.2 lib/jsonapi_compliable/errors.rb
jsonapi_compliable-0.11.1 lib/jsonapi_compliable/errors.rb