Exception: Apia::NullFieldValueError

Inherits:
RuntimeError show all
Defined in:
lib/apia/errors/null_field_value_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field, source) ⇒ NullFieldValueError

Returns a new instance of NullFieldValueError.



10
11
12
13
# File 'lib/apia/errors/null_field_value_error.rb', line 10

def initialize(field, source)
  @field = field
  @source = source
end

Instance Attribute Details

#fieldObject (readonly)

Returns the value of attribute field.



8
9
10
# File 'lib/apia/errors/null_field_value_error.rb', line 8

def field
  @field
end

Instance Method Details

#hashObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/apia/errors/null_field_value_error.rb', line 23

def hash
  {
    code: 'null_value_for_non_null_field',
    description: to_s,
    detail: {
      field: {
        id: @field.id,
        name: @field.name
      }
    }
  }
end

#http_statusObject



19
20
21
# File 'lib/apia/errors/null_field_value_error.rb', line 19

def http_status
  500
end

#to_sObject



15
16
17
# File 'lib/apia/errors/null_field_value_error.rb', line 15

def to_s
  "Value for `#{field.name}` is null (but cannot be)"
end