use of nokogiri.XmlSyntaxError in project gocd by gocd.
the class NokogiriErrorHandler method getErrorsReadyForRuby.
public List<IRubyObject> getErrorsReadyForRuby(ThreadContext context) {
Ruby runtime = context.getRuntime();
List<IRubyObject> res = new ArrayList<IRubyObject>();
for (int i = 0; i < errors.size(); i++) {
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime, "Nokogiri::XML::SyntaxError"));
xmlSyntaxError.setException(errors.get(i));
res.add(xmlSyntaxError);
}
return res;
}
use of nokogiri.XmlSyntaxError in project gocd by gocd.
the class XmlDomParserContext method getDocumentWithErrorsOrRaiseException.
public XmlDocument getDocumentWithErrorsOrRaiseException(ThreadContext context, RubyClass klazz, Exception ex) {
if (options.recover) {
XmlDocument xmlDocument = getInterruptedOrNewXmlDocument(context, klazz);
this.addErrorsIfNecessary(context, xmlDocument);
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(context.getRuntime(), getNokogiriClass(context.getRuntime(), "Nokogiri::XML::SyntaxError"));
xmlSyntaxError.setException(ex);
((RubyArray) xmlDocument.getInstanceVariable("@errors")).append(xmlSyntaxError);
return xmlDocument;
} else {
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(context.getRuntime(), getNokogiriClass(context.getRuntime(), "Nokogiri::XML::SyntaxError"));
xmlSyntaxError.setException(ex);
throw new RaiseException(xmlSyntaxError);
}
}
use of nokogiri.XmlSyntaxError in project nokogiri by sparklemotion.
the class HtmlDomParserContext method parse.
@Override
public XmlDocument parse(ThreadContext context, RubyClass klass, IRubyObject url) {
XmlDocument xmlDoc = super.parse(context, klass, url);
// https://github.com/sparklemotion/nokogiri/issues/2130
if (!options.recover && errorHandler.getErrors().size() > 0) {
XmlSyntaxError xmlSyntaxError = XmlSyntaxError.createXMLSyntaxError(context.runtime);
String exceptionMsg = String.format("%s: '%s'", "Parser without recover option encountered error or warning", errorHandler.getErrors().get(0));
xmlSyntaxError.setException(new Exception(exceptionMsg));
throw xmlSyntaxError.toThrowable();
}
return xmlDoc;
}
use of nokogiri.XmlSyntaxError in project gocd by gocd.
the class SchemaErrorHandler method warning.
public void warning(SAXParseException ex) throws SAXException {
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime, "Nokogiri::XML::SyntaxError"));
xmlSyntaxError.setException(ex);
this.errors.append(xmlSyntaxError);
}
use of nokogiri.XmlSyntaxError in project gocd by gocd.
the class SchemaErrorHandler method error.
public void error(SAXParseException ex) throws SAXException {
XmlSyntaxError xmlSyntaxError = (XmlSyntaxError) NokogiriService.XML_SYNTAXERROR_ALLOCATOR.allocate(runtime, getNokogiriClass(runtime, "Nokogiri::XML::SyntaxError"));
xmlSyntaxError.setException(ex);
this.errors.append(xmlSyntaxError);
}
Aggregations