Exception: Nokogiri::XML::SyntaxError
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Nokogiri::SyntaxError ,
::StandardError ,
Exception
|
|
Instance Chain:
self,
::Nokogiri::SyntaxError ,
::StandardError ,
Exception
|
|
Inherits: |
Nokogiri::SyntaxError
|
Defined in: | lib/nokogiri/xml/syntax_error.rb, ext/nokogiri/xml_syntax_error.c |
Overview
This class provides information about ::Nokogiri::XML
SyntaxErrors. These exceptions are typically stored on Document#errors.
Class Method Summary
Instance Attribute Summary
- #code readonly
- #column readonly
- #domain readonly
-
#error? ⇒ Boolean
readonly
return true if this is an error.
-
#fatal? ⇒ Boolean
readonly
return true if this error is fatal.
- #file readonly
- #int1 readonly
- #level readonly
- #line readonly
-
#none? ⇒ Boolean
readonly
return true if this is a non error.
-
#path
readonly
The XPath path of the node that caused the error when validating a
Document
. - #str1 readonly
- #str2 readonly
- #str3 readonly
-
#warning? ⇒ Boolean
readonly
return true if this is a warning.
Instance Method Summary
- #to_s
- #level_to_s private
- #location_to_s private
- #nil_or_zero?(attribute) ⇒ Boolean private
Class Method Details
.aggregate(errors)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 10
def aggregate(errors) return nil if errors.empty? return errors.first if errors.length == 1 = ["Multiple errors encountered:"] errors.each do |error| << error.to_s end new( .join("\n")) end
Instance Attribute Details
#code (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 23
attr_reader :code
#column (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 40
attr_reader :column
#domain (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 22
attr_reader :domain
#error? ⇒ Boolean
(readonly)
return true if this is an error
# File 'lib/nokogiri/xml/syntax_error.rb', line 56
def error? level == 2 end
#fatal? ⇒ Boolean
(readonly)
return true if this error is fatal
# File 'lib/nokogiri/xml/syntax_error.rb', line 62
def fatal? level == 3 end
#file (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 25
attr_reader :file
#int1 (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 39
attr_reader :int1
#level (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 24
attr_reader :level
#line (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 26
attr_reader :line
#none? ⇒ Boolean
(readonly)
return true if this is a non error
# File 'lib/nokogiri/xml/syntax_error.rb', line 44
def none? level == 0 end
#path (readonly)
The XPath path of the node that caused the error when validating a Document
.
This attribute will only be non-nil when the error is emitted by Schema#validate on Document
objects. It will return nil
for DOM parsing errors and for errors emitted during Schema
validation of files.
⚠ #path
is not supported on JRuby, where it will always return nil
.
# File 'lib/nokogiri/xml/syntax_error.rb', line 35
attr_reader :path
#str1 (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 36
attr_reader :str1
#str2 (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 37
attr_reader :str2
#str3 (readonly)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 38
attr_reader :str3
#warning? ⇒ Boolean
(readonly)
return true if this is a warning
# File 'lib/nokogiri/xml/syntax_error.rb', line 50
def warning? level == 1 end
Instance Method Details
#level_to_s (private)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 75
def level_to_s case level when 3 then "FATAL" when 2 then "ERROR" when 1 then "WARNING" end end
#location_to_s (private)
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 87
def location_to_s return if nil_or_zero?(line) && nil_or_zero?(column) "#{line}:#{column}" end
#nil_or_zero?(attribute) ⇒ Boolean
(private)
# File 'lib/nokogiri/xml/syntax_error.rb', line 83
def nil_or_zero?(attribute) attribute.nil? || attribute.zero? end
#to_s
[ GitHub ]# File 'lib/nokogiri/xml/syntax_error.rb', line 66
def to_s = super.chomp [location_to_s, level_to_s, ] .compact.join(": ") .force_encoding( .encoding) end