Exception: Graphiti::Errors::InvalidFilterValue

Inherits:
Base
  • Object
show all
Defined in:
lib/graphiti/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(resource, filter, value) ⇒ InvalidFilterValue

Returns a new instance of InvalidFilterValue.



162
163
164
165
166
# File 'lib/graphiti/errors.rb', line 162

def initialize(resource, filter, value)
  @resource = resource
  @filter = filter
  @value = value
end

Instance Method Details

#messageObject



168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/graphiti/errors.rb', line 168

def message
  allow = @filter.values[0][:allow]
  deny = @filter.values[0][:deny]
  value_string = if @value == "(empty)"
    "empty value"
  else
    "value #{@value.inspect}"
  end
  msg = <<~MSG
    #{@resource.class.name}: tried to filter on #{@filter.keys[0].inspect}, but passed invalid #{value_string}.
  MSG
  msg << "\nAllowlist: #{allow.inspect}" if allow
  msg << "\nDenylist: #{deny.inspect}" if deny
  msg
end