Exception: JsonSchema::SchemaError

Inherits:
Error
  • Object
show all
Defined in:
lib/json_schema/error.rb

Direct Known Subclasses

ValidationError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schema, message, type) ⇒ SchemaError

Returns a new instance of SchemaError.



24
25
26
27
28
# File 'lib/json_schema/error.rb', line 24

def initialize(schema, message, type)
  @schema = schema
  @message = message
  @type = type
end

Instance Attribute Details

#messageObject

Returns the value of attribute message.



18
19
20
# File 'lib/json_schema/error.rb', line 18

def message
  @message
end

#schemaObject

Returns the value of attribute schema.



18
19
20
# File 'lib/json_schema/error.rb', line 18

def schema
  @schema
end

#typeObject

Returns the value of attribute type.



18
19
20
# File 'lib/json_schema/error.rb', line 18

def type
  @type
end

Class Method Details

.aggregate(errors) ⇒ Object



20
21
22
# File 'lib/json_schema/error.rb', line 20

def self.aggregate(errors)
  errors.map(&:to_s)
end

Instance Method Details

#to_sObject



30
31
32
33
34
35
36
# File 'lib/json_schema/error.rb', line 30

def to_s
  if schema && schema.pointer
    "#{schema.pointer}: #{message}"
  else
    message
  end
end