Exception: Nokogiri::XML::SyntaxError

Inherits:
SyntaxError
  • Object
show all
Defined in:
lib/nokogiri/xml/syntax_error.rb,
ext/nokogiri/xml_syntax_error.c

Instance Method Summary collapse

Instance Method Details

#codeObject

Get the error code



129
130
131
132
133
134
# File 'ext/nokogiri/xml_syntax_error.c', line 129

static VALUE code(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return INT2NUM(error->code);
}

#columnObject

Column number or 0 if not available



16
17
18
19
20
21
# File 'ext/nokogiri/xml_syntax_error.c', line 16

static VALUE column(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return INT2NUM(error->int2);
}

#domainObject

Get the part of the library that raised this exception



142
143
144
145
146
147
# File 'ext/nokogiri/xml_syntax_error.c', line 142

static VALUE domain(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return INT2NUM(error->domain);
}

#error?Boolean

Returns:

  • (Boolean)


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

def error?
  level == 2
end

#fatal?Boolean

Returns:

  • (Boolean)


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

def fatal?
  level == 3
end

#fileObject

Get the filename for the error



100
101
102
103
104
105
106
107
108
# File 'ext/nokogiri/xml_syntax_error.c', line 100

static VALUE file(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  if(error->file)
    return rb_str_new2(error->file);

  return Qnil;
}

#int1Object

Extra number information



29
30
31
32
33
34
# File 'ext/nokogiri/xml_syntax_error.c', line 29

static VALUE int1(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return INT2NUM(error->int1);
}

#levelObject

Get the error level



116
117
118
119
120
121
# File 'ext/nokogiri/xml_syntax_error.c', line 116

static VALUE level(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return INT2NUM((short)error->level);
}

#lineObject

Get the line number of the error



87
88
89
90
91
92
# File 'ext/nokogiri/xml_syntax_error.c', line 87

static VALUE line(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return INT2NUM(error->line);
}

#messageObject

Get the human readable message.



155
156
157
158
159
160
# File 'ext/nokogiri/xml_syntax_error.c', line 155

static VALUE message(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  return rb_str_new2(error->message);
}

#none?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/nokogiri/xml/syntax_error.rb', line 4

def none?
  level == 0
end

#str1Object

Extra string information



72
73
74
75
76
77
78
79
# File 'ext/nokogiri/xml_syntax_error.c', line 72

static VALUE str1(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  if(error->str1)
    return rb_str_new2(error->str1);
  return Qnil;
}

#str2Object

Extra string information



57
58
59
60
61
62
63
64
# File 'ext/nokogiri/xml_syntax_error.c', line 57

static VALUE str2(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  if(error->str2)
    return rb_str_new2(error->str2);
  return Qnil;
}

#str3Object

Extra string information



42
43
44
45
46
47
48
49
# File 'ext/nokogiri/xml_syntax_error.c', line 42

static VALUE str3(VALUE self)
{
  xmlErrorPtr error;
  Data_Get_Struct(self, xmlError, error);
  if(error->str3)
    return rb_str_new2(error->str3);
  return Qnil;
}

#warning?Boolean

Returns:

  • (Boolean)


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

def warning?
  level == 1
end