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
-
#cstruct ⇒ Object
Returns the value of attribute cstruct.
Class Method Summary collapse
Instance Method Summary collapse
-
#code ⇒ Object
Get the error code.
-
#column ⇒ Object
(also: #int2)
Column number or 0 if not available.
-
#domain ⇒ Object
Get the part of the library that raised this exception.
-
#error? ⇒ Boolean
return true if this is an error.
-
#fatal? ⇒ Boolean
return true if this error is fatal.
-
#file ⇒ Object
Get the filename for the error.
-
#initialize(message) ⇒ SyntaxError
constructor
A new instance of SyntaxError.
-
#initialize_copy(old_copy) ⇒ Object
Initialize a copy of the
old_copy
. -
#int1 ⇒ Object
Extra number information.
-
#level ⇒ Object
Get the error level.
-
#line ⇒ Object
Get the line number of the error.
-
#message ⇒ Object
(also: #inspect, #to_s)
Get the human readable message.
-
#message= ⇒ Object
Set the human readable message.
-
#none? ⇒ Boolean
return true if this is a non error.
-
#str1 ⇒ Object
Extra string information.
-
#str2 ⇒ Object
Extra string information.
-
#str3 ⇒ Object
Extra string information.
-
#warning? ⇒ Boolean
return true if this is a warning.
Constructor Details
#initialize(message) ⇒ SyntaxError
Returns a new instance of SyntaxError.
7 8 9 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 7 def initialize self. = end |
Instance Attribute Details
#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 |
Class Method Details
.error_array_pusher(array) ⇒ Object
71 72 73 74 75 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 71 def error_array_pusher(array) Proc.new do |_ignored_, error| array << wrap(error) if array end end |
.wrap(error_ptr) ⇒ Object
77 78 79 80 81 82 83 84 |
# File 'lib/nokogiri/ffi/xml/syntax_error.rb', line 77 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
#code ⇒ Object
Get the error code
133 134 135 |
# File 'ext/nokogiri/xml_syntax_error.c', line 133 def code cstruct[:code] end |
#column ⇒ Object Also known as: int2
Column number or 0 if not available
24 25 26 |
# File 'ext/nokogiri/xml_syntax_error.c', line 24 def column cstruct[:int2] end |
#domain ⇒ Object
Get the part of the library that raised this exception
146 147 148 |
# File 'ext/nokogiri/xml_syntax_error.c', line 146 def domain cstruct[:domain] end |
#error? ⇒ Boolean
return true if this is an error
25 26 27 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 25 def error? level == 2 end |
#fatal? ⇒ Boolean
return true if this error is fatal
31 32 33 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 31 def fatal? level == 3 end |
#file ⇒ Object
Get the filename for the error
105 106 107 |
# File 'ext/nokogiri/xml_syntax_error.c', line 105 def file cstruct[:file].null? ? nil : cstruct[:file] end |
#initialize_copy(old_copy) ⇒ Object
Initialize a copy of the old_copy
198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'ext/nokogiri/xml_syntax_error.c', line 198
static VALUE initialize_copy(VALUE self, VALUE _old_copy)
{
if(!rb_obj_is_kind_of(_old_copy, cNokogiriXmlSyntaxError))
rb_raise(rb_eArgError, "node must be a Nokogiri::XML::SyntaxError");
xmlErrorPtr error, old_error;
Data_Get_Struct(self, xmlError, error);
Data_Get_Struct(_old_copy, xmlError, old_error);
xmlCopyError(old_error, error);
return message;
}
|
#int1 ⇒ Object
Extra number information
37 38 39 |
# File 'ext/nokogiri/xml_syntax_error.c', line 37 def int1 cstruct[:int1] end |
#level ⇒ Object
Get the error level
120 121 122 |
# File 'ext/nokogiri/xml_syntax_error.c', line 120 def level cstruct[:level] end |
#line ⇒ Object
Get the line number of the error
92 93 94 |
# File 'ext/nokogiri/xml_syntax_error.c', line 92 def line cstruct[:line] end |
#message ⇒ Object Also known as: inspect, to_s
Get the human readable message.
159 160 161 162 |
# File 'ext/nokogiri/xml_syntax_error.c', line 159 def val = cstruct[:message] val.null? ? nil : val.read_string end |
#message= ⇒ Object
Set the human readable message.
173 174 175 176 177 178 |
# File 'ext/nokogiri/xml_syntax_error.c', line 173 def (string) unless cstruct[:message].null? LibXML.xmlFree(cstruct[:message]) end cstruct[:message] = string end |
#none? ⇒ Boolean
return true if this is a non error
13 14 15 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 13 def none? level == 0 end |
#str1 ⇒ Object
Extra string information
78 79 80 |
# File 'ext/nokogiri/xml_syntax_error.c', line 78 def str1 cstruct[:str1].null? ? nil : cstruct[:str1] end |
#str2 ⇒ Object
Extra string information
64 65 66 |
# File 'ext/nokogiri/xml_syntax_error.c', line 64 def str2 cstruct[:str].null? ? nil : cstruct[:str] end |
#str3 ⇒ Object
Extra string information
50 51 52 |
# File 'ext/nokogiri/xml_syntax_error.c', line 50 def str3 cstruct[:str3].null? ? nil : cstruct[:str3] end |
#warning? ⇒ Boolean
return true if this is a warning
19 20 21 |
# File 'lib/nokogiri/xml/syntax_error.rb', line 19 def warning? level == 1 end |