Skip to content

Unintuitive error message when encoding is omitted #649

@blowfishpro

Description

@blowfishpro

Simplified example:

root = Kramdown::Element.new(:root)
root.children << Kramdown::Element.new(:text, 'stuff')
Kramdown::Converter::Kramdown.convert(root)

        2: from /Users/joey/.rvm/gems/ruby-2.6.3/gems/kramdown-2.1.0/lib/kramdown/converter/base.rb:109:in `convert'
        1: from /Users/joey/.rvm/gems/ruby-2.6.3/gems/kramdown-2.1.0/lib/kramdown/converter/base.rb:109:in `encode!'
TypeError (no implicit conversion of nil into String)

what works:

root = Kramdown::Element.new(:root, nil, nil, encoding: Encoding::UTF_8)

Now, it makes sense that an encoding is needed. But the error it produces doesn't really point to the source of the problem at all - I had to look at kramdown's source to figure out what was actually wrong.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions