Exception: Textus::SchemaViolation

Inherits:
Error
  • Object
show all
Defined in:
lib/textus/errors.rb

Instance Attribute Summary

Attributes inherited from Error

#code, #details, #exit_code, #hint

Instance Method Summary collapse

Methods inherited from Error

#to_envelope

Constructor Details

#initialize(d) ⇒ SchemaViolation

Returns a new instance of SchemaViolation.



75
76
77
78
79
80
81
82
83
# File 'lib/textus/errors.rb', line 75

def initialize(d)
  hint =
    if d.is_a?(Hash) && d["missing"]
      "add the missing field(s) to the entry's frontmatter: #{Array(d["missing"]).join(", ")}"
    elsif d.is_a?(Hash) && d["field"]
      "fix the field '#{d["field"]}' in the entry's frontmatter (#{d["reason"]})"
    end
  super("schema_violation", "schema violation", details: d, hint: hint)
end