我对数据库中的html_document
列进行了自定义验证:
def html_format
bad_doc = Nokogiri::HTML(html_document) { |config| config.strict }
bad_doc.errors.each do |e|
errors.add(:html_document, [e.message,e.line].join(' at line: '))
end if bad_doc.errors.present?
end
我想为几种语言翻译返回的错误。从Nokogiri返回的错误如下:
Unexpected end tag : p
我已经通过浏览Nokogiri文档了解到我可以检查返回错误的数量:
[1] pry(#<Model>)> errors.first.code
=> 76
我有一个想法,可以通过给定的代码进行翻译 问题是,在哪里可以找到错误代码和消息的完整表格?
答案 0 :(得分:1)
您需要查看libxml2源代码。