
Issue #19570 has been updated by nobu (Nobuyoshi Nakada). https://github.com/ruby/ruby/pull/7681 ---------------------------------------- Bug #19570: `Exception#full_message` raises an `EncodingError` if the exception contains UTF8 characters after a newline and `Exception#cause` contains UTF8 characters https://bugs.ruby-lang.org/issues/19570#change-102710 * Author: timothy.willard (Timothy Willard) * Status: Open * Priority: Normal * ruby -v: 3.2.1 * Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONTNEED, 3.2: UNKNOWN ---------------------------------------- ``` e = begin begin raise "Übersicht" rescue => e raise "\n#{e.message}" end rescue => e e end e.full_message ``` will reproduce the error with the exception `incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)`. In this case, all of `e.message`, `e.cause.message` and `e.cause.detailed_message` have a UTF-8 encoding, but `e.detailed_message` has an ASCII-8BIT encoding. I think the issue is related to [this](https://github.com/ruby/ruby/blob/31819e82c88c6f8ecfaeb162519bfa26a14b21fd/e...) line (possibly caused by the encoding differences between `write_warn2` used [here](https://github.com/ruby/ruby/blob/31819e82c88c6f8ecfaeb162519bfa26a14b21fd/e...) and [here](https://github.com/ruby/ruby/blob/31819e82c88c6f8ecfaeb162519bfa26a14b21fd/e...) in the newline case vs `write_warn_str` used [here](https://github.com/ruby/ruby/blob/31819e82c88c6f8ecfaeb162519bfa26a14b21fd/e...) in the no-newline case. -- https://bugs.ruby-lang.org/