Skip to content

Instantly share code, notes, and snippets.

@adamflorin
Created October 18, 2013 18:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save adamflorin/7045640 to your computer and use it in GitHub Desktop.
Save adamflorin/7045640 to your computer and use it in GitHub Desktop.
Repeatedly raising errors in Redcarpet formatting callbacks eventually crashes Redcarpet instance.
require 'redcarpet'
# Custom handler that raises error.
#
module Redcarpet
module Render
class Crasher < HTML
def paragraph(text)
raise "Error!"
end
end
end
end
redcarpet = Redcarpet::Markdown.new Redcarpet::Render::Crasher
# Will loop a certain number of times (always 17 for me for some reason)
# and then CRASH with:
#
# Assertion failed: (md->work_bufs[BUFFER_BLOCK].size == 0), function sd_markdown_render, file markdown.c, line 2544.
# Abort trap: 6
#
20.times do
begin
redcarpet.render "Body text."
rescue RuntimeError => e
puts "Error: #{e.message}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment