use of nokogiri.XmlSyntaxError in project nokogiri by sparklemotion.
the class XmlDomParserContext method mapErrors.
public static RubyArray mapErrors(ThreadContext context, NokogiriErrorHandler errorHandler) {
final Ruby runtime = context.runtime;
final List<Exception> errors = errorHandler.getErrors();
final IRubyObject[] errorsAry = new IRubyObject[errors.size()];
for (int i = 0; i < errors.size(); i++) {
XmlSyntaxError xmlSyntaxError = XmlSyntaxError.createXMLSyntaxError(runtime);
xmlSyntaxError.setException(errors.get(i));
errorsAry[i] = xmlSyntaxError;
}
return runtime.newArrayNoCopy(errorsAry);
}
use of nokogiri.XmlSyntaxError in project nokogiri by sparklemotion.
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.createXMLSyntaxError(context.runtime);
xmlSyntaxError.setException(ex);
((RubyArray) xmlDocument.getInstanceVariable("@errors")).append(xmlSyntaxError);
return xmlDocument;
} else {
XmlSyntaxError xmlSyntaxError = XmlSyntaxError.createXMLSyntaxError(context.runtime);
xmlSyntaxError.setException(ex);
throw xmlSyntaxError.toThrowable();
}
}
Aggregations