# Object as second parameter to raise

**URL:** <https://www.ruby-forum.com/t/object-as-second-parameter-to-raise/173567>\
**Category:** Ruby\
**Created:** [August 11, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/object-as-second-parameter-to-raise/173567 "2009-08-11T15:00:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/bbe5ce/32.png) [@paul](https://www.ruby-forum.com/u/paul)\
**Post date:** [August 11, 2009, 3:00pm UTC](https://www.ruby-forum.com/t/object-as-second-parameter-to-raise/173567/1 "2009-08-11T15:00:17Z")

</div>

Hi

I’ve just realised that I’ve been inadvertently passing objects other  
than strings to raise. As in this example:

class Foo  
def bar  
:bar  
end  
end

begin  
raise RuntimeError, Foo.new  
rescue =\> e  
puts e.message.bar # prints bar in 1.8.6 MRI and 1.9.1 YARV  
end

While this works, and is quite useful, I suspect it’s an artefact and  
isn’t supported in other Ruby VMs?

Thanks

Paul
