Exception: Nokogiri::XML::SyntaxError
- Inherits:
-
SyntaxError
- Object
- StandardError
- SyntaxError
- Nokogiri::XML::SyntaxError
- Defined in:
- lib/nokogiri/xml/syntax_error.rb,
lib/nokogiri/ffi/xml/syntax_error.rb,
ext/nokogiri/xml_syntax_error.c
Overview
This class provides information about XML SyntaxErrors. These exceptions are typically stored on Nokogiri::XML::Document#errors.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#column ⇒ Object
(also: #int2)
readonly
Returns the value of attribute column.
-
#cstruct ⇒ Object
Returns the value of attribute cstruct.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#int1 ⇒ Object
readonly
Returns the value of attribute int1.
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#line ⇒ Object
readonly
Returns the value of attribute line.
-
#str1 ⇒ Object
readonly
Returns the value of attribute str1.
-
#str2 ⇒ Object
readonly
Returns the value of attribute str2.
-
#str3 ⇒ Object
readonly
Returns the value of attribute str3.
Class Method Summary collapse
Instance Method Summary collapse
-
#error? ⇒ Boolean
return true if this is an error.
-
#fatal? ⇒ Boolean
return true if this error is fatal.
-
#initialize(message) ⇒ SyntaxError
constructor
A new instance of SyntaxError.
- #initialize_copy(other) ⇒ Object
- #message ⇒ Object (also: #inspect, #to_s)
- #message=(string) ⇒ Object
-
#none? ⇒ Boolean
return true if this is a non error.
-
#warning? ⇒ Boolean
return true if this is a warning.
Constructor Details
#initialize(message) ⇒ SyntaxError
Returns a new instance of SyntaxError.
8 9 10 11 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 8 def initialize() self.cstruct = LibXML::XmlSyntaxError.new(LibXML::XmlSyntaxError.allocate()) self.cstruct[:message] = LibXML.xmlStrdup() end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
8 9 10 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 8 def code @code end |
#column ⇒ Object (readonly) Also known as: int2
Returns the value of attribute column.
16 17 18 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 16 def column @column end |
#cstruct ⇒ Object
Returns the value of attribute cstruct.
6 7 8 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 6 def cstruct @cstruct end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
7 8 9 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 7 def domain @domain end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
10 11 12 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 10 def file @file end |
#int1 ⇒ Object (readonly)
Returns the value of attribute int1.
15 16 17 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 15 def int1 @int1 end |
#level ⇒ Object (readonly)
Returns the value of attribute level.
9 10 11 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 9 def level @level end |
#line ⇒ Object (readonly)
Returns the value of attribute line.
11 12 13 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 11 def line @line end |
#str1 ⇒ Object (readonly)
Returns the value of attribute str1.
12 13 14 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 12 def str1 @str1 end |
#str2 ⇒ Object (readonly)
Returns the value of attribute str2.
13 14 15 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 13 def str2 @str2 end |
#str3 ⇒ Object (readonly)
Returns the value of attribute str3.
14 15 16 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 14 def str3 @str3 end |
Class Method Details
.error_array_pusher(array) ⇒ Object
78 79 80 81 82 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 78 def error_array_pusher(array) Proc.new do |_ignored_, error| array << wrap(error) if array end end |
.wrap(error_ptr) ⇒ Object
84 85 86 87 88 89 90 91 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 84 def wrap(error_ptr) error_struct = LibXML::XmlSyntaxError.allocate LibXML.xmlCopyError(error_ptr, error_struct) error_cstruct = LibXML::XmlSyntaxError.new(error_struct) error = self.allocate # will generate XML::XPath::SyntaxError or XML::SyntaxError error.cstruct = error_cstruct error end |
Instance Method Details
#error? ⇒ Boolean
return true if this is an error
32 33 34 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 32 def error? level == 2 end |
#fatal? ⇒ Boolean
return true if this error is fatal
38 39 40 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 38 def fatal? level == 3 end |
#initialize_copy(other) ⇒ Object
38 39 40 41 42 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 38 def initialize_copy(other) raise ArgumentError, "node must be a Nokogiri::XML::SyntaxError" unless other.is_a?(Nokogiri::XML::SyntaxError) LibXML.xmlCopyError(other.cstruct, cstruct) self end |
#message ⇒ Object Also known as: inspect, to_s
21 22 23 24 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 21 def val = cstruct[:message] val.null? ? nil : val.read_string.chomp end |
#message=(string) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 30 def (string) unless cstruct[:message].null? LibXML.xmlFree(cstruct[:message]) end cstruct[:message] = LibXML.xmlStrdup(string) string end |
#none? ⇒ Boolean
return true if this is a non error
20 21 22 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 20 def none? level == 0 end |
#warning? ⇒ Boolean
return true if this is a warning
26 27 28 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 26 def warning? level == 1 end |