Module: Telebugs::ErrorMessage
- Defined in:
- lib/telebugs/error_message.rb
Overview
Parses error messages to make them more consistent.
Constant Summary collapse
- RUBY_31_ERROR_HIGHLIGHTING_DIVIDER =
On Ruby 3.1+, the error highlighting gem can produce messages that can span over multiple lines. We don’t want to display multiline error titles. Therefore, we want to strip out the higlighting part so that the errors look consistent.
"\n\n"
- ENCODING_OPTIONS =
The options for String#encode
{invalid: :replace, undef: :replace}.freeze
Class Method Summary collapse
Class Method Details
.parse(error) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/telebugs/error_message.rb', line 15 def self.parse(error) return unless (msg = error.) msg.encode(Encoding::UTF_8, **ENCODING_OPTIONS) .split(RUBY_31_ERROR_HIGHLIGHTING_DIVIDER) .first end |