From: Brian Candler Date: 2003-08-14T00:09:17+09:00 Subject: Exception reporting change? There appears to have been a change in exception handling in ruby-1.8. In 1.6.8 I was able to create an object containing detailled information about the exception for the benefit of the receiver, and pass it in the 'message' field: ------------------------------------------------------------------------ class Code def initialize(code, text) @code = code @text = text end def to_s "#{@text} (#{@code})" end def to_str @text end end begin raise StandardError, Code.new(550, "Relaying Denied") rescue Exception => e p $!.class p $!.message.class puts "Error: #{$!}" puts "Error: #{$!.message}" end ------------------------------------------------------------------------ Under 1.6.8 this gives: StandardError Code Error: # Error: Relaying Denied (550) But under 1.8.0 I get: StandardError String Error: Relaying Denied Error: Relaying Denied It appears that my information object has been flattened into a string before the exception itself is raised. Was this intentional? If so, what should I do now? Would it be better to embed my information directly in an exception object: class MyException < StandardError def initialize(code, text) @code = code @text = text end end ... raise MyException.new(550,"Relaying Denied") I have this sort of thing all over my code, so I want to know the official supported way of doing this before I start changing it all :-) Thanks... Brian.