Sorry for the strange title, I’m not really sure how to classify this issue. I’m in the process of updating some ruby code to 1.9.3, and am seeing some strange behavior. Distilling the issue, I get:
def convert(exception)
raise exception.message
end
begin
convert(StandardError.new(StandardError))
rescue => e
puts e.class
end
In 1.9.2, the output is
StandardError
and in 1.9.3, te output is
RuntimeError
Looking though the ruby docs and release notes hasn’t really given me any clues as to what could be going on here, and any help is appreciated!
The issue seems to be that prior to 1.9.3,
Exception#messagereturned an object of classClass, notString, which causes weird things to happen and it ends up raising an exception with an unexpected class (i.e., notRuntimeError).This bug was fixed in this commit, and it is present in the 1.9.3 changelog.
Ultimately, you do want to
raise exception, notraise exception.message.