FoundChris.com - Blog of Chris Johnson

A handy monkey-patch: Add to_xml to Ruby's StandardError

May 28th 2009

While working on some error handler refactoring in a Rails app, I added this bit of code to my application controller (application.rb):

Then I found that the method StandardError#to_xml that I expected to be defined, actually was not. So I put this into an initializer:

Itch scratched!