Sha256: e0308e3c78edb005ec5e8d30d699b4ddf7081bdfccbe6498e649d357778e2719

Contents?: true

Size: 1.81 KB

Versions: 58

Compression:

Stored size: 1.81 KB

Contents

#include <xml_syntax_error.h>

void Nokogiri_error_array_pusher(void * ctx, xmlErrorPtr error)
{
  VALUE list = (VALUE)ctx;
  Check_Type(list, T_ARRAY);
  rb_ary_push(list,  Nokogiri_wrap_xml_syntax_error(error));
}

void Nokogiri_error_silencer(void * ctx, xmlErrorPtr error)
{
}

void Nokogiri_error_raise(void * ctx, xmlErrorPtr error)
{
  rb_exc_raise(Nokogiri_wrap_xml_syntax_error(error));
}

VALUE Nokogiri_wrap_xml_syntax_error(xmlErrorPtr error)
{
  VALUE msg, e, klass;

  klass = cNokogiriXmlSyntaxError;

  if (error && error->domain == XML_FROM_XPATH) {
    VALUE xpath = rb_const_get(mNokogiriXml, rb_intern("XPath"));
    klass = rb_const_get(xpath, rb_intern("SyntaxError"));
  }

  msg = (error && error->message) ? NOKOGIRI_STR_NEW2(error->message) : Qnil;

  e = rb_class_new_instance(
      1,
      &msg,
      klass
  );

  if (error)
  {
    rb_iv_set(e, "@domain", INT2NUM(error->domain));
    rb_iv_set(e, "@code", INT2NUM(error->code));
    rb_iv_set(e, "@level", INT2NUM((short)error->level));
    rb_iv_set(e, "@file", RBSTR_OR_QNIL(error->file));
    rb_iv_set(e, "@line", INT2NUM(error->line));
    rb_iv_set(e, "@str1", RBSTR_OR_QNIL(error->str1));
    rb_iv_set(e, "@str2", RBSTR_OR_QNIL(error->str2));
    rb_iv_set(e, "@str3", RBSTR_OR_QNIL(error->str3));
    rb_iv_set(e, "@int1", INT2NUM(error->int1));
    rb_iv_set(e, "@column", INT2NUM(error->int2));
  }

  return e;
}

VALUE cNokogiriXmlSyntaxError;
void init_xml_syntax_error()
{
  VALUE nokogiri = rb_define_module("Nokogiri");
  VALUE xml = rb_define_module_under(nokogiri, "XML");

  /*
   * The XML::SyntaxError is raised on parse errors
   */
  VALUE syntax_error_mommy = rb_define_class_under(nokogiri, "SyntaxError", rb_eStandardError);
  VALUE klass = rb_define_class_under(xml, "SyntaxError", syntax_error_mommy);
  cNokogiriXmlSyntaxError = klass;

}

Version data entries

58 entries across 58 versions & 8 rubygems

Version Path
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_syntax_error.c
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_syntax_error.c
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_syntax_error.c
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_syntax_error.c
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_syntax_error.c
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_syntax_error.c
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_syntax_error.c
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_syntax_error.c
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.2 ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.2-x86-mingw32 ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.2-x64-mingw32 ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.2-java ext/nokogiri/xml_syntax_error.c
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/ext/nokogiri/xml_syntax_error.c
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/nokogiri-1.6.7.1/ext/nokogiri/xml_syntax_error.c
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/ext/nokogiri/xml_syntax_error.c
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/nokogiri-1.6.6.2/ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.1 ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.1-x86-mingw32 ext/nokogiri/xml_syntax_error.c
nokogiri-1.6.7.1-x64-mingw32 ext/nokogiri/xml_syntax_error.c