123456789_123456789_123456789_123456789_123456789_

Exception: Nokogiri::XML::SyntaxError

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Subclasses:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
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.

Instance Attribute Summary

Instance Method Summary

Instance Attribute Details

#code (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 10

attr_reader :code

#column (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 18

attr_reader :column

#domain (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 9

attr_reader :domain

#error?Boolean (readonly)

return true if this is an error

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 34

def error?
  level == 2
end

#fatal?Boolean (readonly)

return true if this error is fatal

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 40

def fatal?
  level == 3
end

#file (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 12

attr_reader :file

#int1 (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 17

attr_reader :int1

#level (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 11

attr_reader :level

#line (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 13

attr_reader :line

#none?Boolean (readonly)

return true if this is a non error

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 22

def none?
  level == 0
end

#str1 (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 14

attr_reader :str1

#str2 (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 15

attr_reader :str2

#str3 (readonly)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 16

attr_reader :str3

#warning?Boolean (readonly)

return true if this is a warning

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 28

def warning?
  level == 1
end

Instance Method Details

#level_to_s (private)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 53

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 65

def location_to_s
  return if nil_or_zero?(line) && nil_or_zero?(column)

  "#{line}:#{column}"
end

#nil_or_zero?(attribute) ⇒ Boolean (private)

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 61

def nil_or_zero?(attribute)
  attribute.nil? || attribute.zero?
end

#to_s

[ GitHub ]

  
# File 'lib/nokogiri/xml/syntax_error.rb', line 44

def to_s
  message = super.chomp
  [location_to_s, level_to_s, message]
    .compact.join(": ")
    .force_encoding(message.encoding)
end