Class: ActiveMail::ParseErrorReporter
- Inherits:
-
Object
- Object
- ActiveMail::ParseErrorReporter
- Extended by:
- T::Sig
- Defined in:
- lib/activemail/parse_error_reporter.rb
Overview
Surfaces libxml2 recover-mode repairs that would otherwise silently change the rendered email, honoring ActiveMail.configuration.on_parse_error.
Instance Method Summary collapse
- #call(errors) ⇒ Object
-
#initialize(known_tags) ⇒ ParseErrorReporter
constructor
A new instance of ParseErrorReporter.
Constructor Details
#initialize(known_tags) ⇒ ParseErrorReporter
Returns a new instance of ParseErrorReporter.
15 16 17 18 |
# File 'lib/activemail/parse_error_reporter.rb', line 15 def initialize() # dup.freeze: the caller's array stays decoupled and cannot be mutated under us. @known_tags = T.let(.dup.freeze, T::Array[String]) end |
Instance Method Details
#call(errors) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/activemail/parse_error_reporter.rb', line 21 def call(errors) mode = ::ActiveMail.configuration.on_parse_error return if mode == :ignore relevant = errors.reject { |error| known_tag_error?(error) } return if relevant.empty? = relevant.map { |error| error..to_s.strip }.join('; ') raise ActiveMail::ParseError, if mode == :raise ::ActiveMail.log_warning("[activemail] HTML parse issues: #{}") end |