# Exception handling discrepancies

**URL:** <https://www.ruby-forum.com/t/exception-handling-discrepancies/135030>\
**Category:** IronRuby\
**Created:** [April 17, 2008, 10:40am UTC](https://www.ruby-forum.com/t/exception-handling-discrepancies/135030 "2008-04-17T10:40:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [April 17, 2008, 10:40am UTC](https://www.ruby-forum.com/t/exception-handling-discrepancies/135030/1 "2008-04-17T10:40:49Z")

</div>

Consider following simple program exceptions.rb:

begin  
a = ABC  
rescue  
puts "We have exception: " + $!  
end

cruby can treat the exception as string, but rbx fails:

[11:24:38 ~/irb\_test] ruby exceptions.rb  
We have exception: uninitialized constant ABC

[11:25:10 ~/irb\_test] rbx exceptions.rb  
Snippets:0:in `main': undefined local variable or method `to\_str’ for  
uninitialized constant Object:🔤NameError (NoMethodError)  
from Snippets:0:in `Initialize’[11:25:16 ~/irb\_test]

The problem can be circumvented currently with to\_s:

puts "We have exception: " + $!.to\_s

Robert B.  
Software architect  
Napa Ltd  
Tammasaarenkatu 3, Helsinki FI-00180  
P.O.Box 470, Helsinki FI-00181

Tel. +358 9 22 813 1  
Direct. +358 9 22 813 611  
GSM +358 45 11 456 02  
Fax. +358 9 22 813 800

Email: removed\_email\_address@domain.invalid [mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
[www.napa.fi](http://www.napa.fi) [http://www.napa.fi/](http://www.napa.fi/)

---

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [April 17, 2008, 11:59am UTC](https://www.ruby-forum.com/t/exception-handling-discrepancies/135030/2 "2008-04-17T11:59:02Z")

</div>

These bugs are great. Are you reporting them on the RubyForge IronRuby  
site? That way they won’t get lost in the mailing list archives.

Pete

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Robert  
Brotherus  
Sent: Thursday,17 April 17, 2008 09:31  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Exception handling discrepancies

Consider following simple program exceptions.rb:

begin  
a = ABC  
rescue  
puts "We have exception: " + $!  
end

cruby can treat the exception as string, but rbx fails:

[11:24:38 ~/irb\_test] ruby exceptions.rb  
We have exception: uninitialized constant ABC

[11:25:10 ~/irb\_test] rbx exceptions.rb  
Snippets:0:in `main': undefined local variable or method `to\_str’ for  
uninitialized constant Object:🔤NameError (NoMethodError)  
from Snippets:0:in `Initialize’[11:25:16 ~/irb\_test]

The problem can be circumvented currently with to\_s:

puts "We have exception: " + $!.to\_s

Robert B.  
Software architect  
Napa Ltd  
Tammasaarenkatu 3, Helsinki FI-00180  
P.O.Box 470, Helsinki FI-00181

Tel. +358 9 22 813 1  
Direct. +358 9 22 813 611  
GSM +358 45 11 456 02  
Fax. +358 9 22 813 800

Email: removed\_email\_address@domain.invalid  
[www.napa.fi](http://www.napa.fi) [http://www.napa.fi/](http://www.napa.fi/)

---

<div class="post-metadata">

**Author:** ![rjberry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/34f0e0/32.png) [@rjberry](https://www.ruby-forum.com/u/rjberry)\
**Post date:** [April 18, 2008, 9:31am UTC](https://www.ruby-forum.com/t/exception-handling-discrepancies/135030/3 "2008-04-18T09:31:03Z")

</div>

Bugs 19625 and 19626 submitted to the tracker. Will submit bugs directly  
there in the future.

Thanks for reminder.  
Robert B.  
Software architect  
Napa Ltd

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Peter Bacon  
Darwin  
Sent: 17. huhtikuuta 2008 12:52  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] Exception handling discrepancies

These bugs are great. Are you reporting them on the RubyForge IronRuby  
site? That way they won’t get lost in the mailing list archives.

Pete

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Robert  
Brotherus  
Sent: Thursday,17 April 17, 2008 09:31  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Exception handling discrepancies

Consider following simple program exceptions.rb:

begin  
a = ABC  
rescue  
puts "We have exception: " + $!  
end

cruby can treat the exception as string, but rbx fails:

[11:24:38 ~/irb\_test] ruby exceptions.rb  
We have exception: uninitialized constant ABC

[11:25:10 ~/irb\_test] rbx exceptions.rb  
Snippets:0:in `main': undefined local variable or method `to\_str’ for  
uninitialized constant Object:🔤NameError (NoMethodError)  
from Snippets:0:in `Initialize’[11:25:16 ~/irb\_test]

The problem can be circumvented currently with to\_s:

puts "We have exception: " + $!.to\_s

Robert B.  
Software architect  
Napa Ltd  
Tammasaarenkatu 3, Helsinki FI-00180  
P.O.Box 470, Helsinki FI-00181

Tel. +358 9 22 813 1  
Direct. +358 9 22 813 611  
GSM +358 45 11 456 02  
Fax. +358 9 22 813 800

Email: removed\_email\_address@domain.invalid  
[www.napa.fi](http://www.napa.fi) [http://www.napa.fi/](http://www.napa.fi/)
