Exception: WCC::Contentful::ValidationError
- Inherits:
-
StandardError
- Object
- StandardError
- WCC::Contentful::ValidationError
- Defined in:
- lib/wcc/contentful/exceptions.rb
Defined Under Namespace
Classes: Message
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Class Method Summary collapse
-
.join_msg_keys(hash) ⇒ Object
Turns the error messages hash into an array of message structs like: menu.fields.name.type: must be equal to String.
Instance Method Summary collapse
-
#initialize(errors) ⇒ ValidationError
constructor
A new instance of ValidationError.
Constructor Details
#initialize(errors) ⇒ ValidationError
Returns a new instance of ValidationError.
14 15 16 17 |
# File 'lib/wcc/contentful/exceptions.rb', line 14 def initialize(errors) @errors = ValidationError.join_msg_keys(errors) super("Content Type Schema from Contentful failed validation!\n #{@errors.join("\n ")}") end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
12 13 14 |
# File 'lib/wcc/contentful/exceptions.rb', line 12 def errors @errors end |
Class Method Details
.join_msg_keys(hash) ⇒ Object
Turns the error messages hash into an array of message structs like: menu.fields.name.type: must be equal to String
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/wcc/contentful/exceptions.rb', line 21 def self.join_msg_keys(hash) ret = hash.map do |k, v| if v.is_a?(Hash) msgs = join_msg_keys(v) msgs.map { |msg| Message.new(k.to_s + '.' + msg.path, msg.error) } else v.map { |msg| Message.new(k.to_s, msg) } end end ret.flatten(1) end |