Exception: Gitgo::Document::InvalidDocumentError
- Inherits:
-
StandardError
- Object
- StandardError
- Gitgo::Document::InvalidDocumentError
- Defined in:
- lib/gitgo/document/invalid_document_error.rb
Overview
Raised by Document#validate for an invalid document.
Instance Attribute Summary collapse
-
#doc ⇒ Object
readonly
Returns the value of attribute doc.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #format_errors ⇒ Object
- #header(n) ⇒ Object
-
#initialize(doc, errors) ⇒ InvalidDocumentError
constructor
A new instance of InvalidDocumentError.
Constructor Details
#initialize(doc, errors) ⇒ InvalidDocumentError
Returns a new instance of InvalidDocumentError.
8 9 10 11 12 |
# File 'lib/gitgo/document/invalid_document_error.rb', line 8 def initialize(doc, errors) @doc = doc @errors = errors super format_errors end |
Instance Attribute Details
#doc ⇒ Object (readonly)
Returns the value of attribute doc.
5 6 7 |
# File 'lib/gitgo/document/invalid_document_error.rb', line 5 def doc @doc end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
6 7 8 |
# File 'lib/gitgo/document/invalid_document_error.rb', line 6 def errors @errors end |
Instance Method Details
#format_errors ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gitgo/document/invalid_document_error.rb', line 14 def format_errors lines = [] errors.keys.sort.each do |key| error = errors[key] lines << "#{key}: #{error.} (#{error.class})" end lines.unshift header(lines.length) lines.join("\n") end |
#header(n) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/gitgo/document/invalid_document_error.rb', line 25 def header(n) case n when 0 then "unknown errors" when 1 then "found 1 error:" else "found #{n} errors:" end end |