Sha256: 2ebed76badd3b8030a5542dad97b3ddecbffaee97a71913c368668261188b065
Contents?: true
Size: 993 Bytes
Versions: 3
Compression:
Stored size: 993 Bytes
Contents
# frozen_string_literal: true module WCC::Contentful class ValidationError < StandardError Message = Struct.new(:path, :error) do def to_s "#{path}: #{error}" end end attr_reader :errors def initialize(errors) @errors = ValidationError.join_msg_keys(errors) super("Content Type Schema from Contentful failed validation!\n #{@errors.join("\n ")}") end # Turns the error messages hash into an array of message structs like: # menu.fields.name.type: must be equal to String 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 end class SyncError < StandardError end class ContentTypeNotFoundError < NameError end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
wcc-contentful-0.2.2 | lib/wcc/contentful/exceptions.rb |
wcc-contentful-0.2.1 | lib/wcc/contentful/exceptions.rb |
wcc-contentful-0.2.0 | lib/wcc/contentful/exceptions.rb |