1、异常的相等性,如果两个异常的class、message和backtrace一样,那么认为这两个异常是相等的,可以通过==判断。
def method
raise 'foobar'
end
errors = []
2.times do
thread.new do
begin
method
rescue => e
errors << e
end
end.join
puts errors[-2] == errors[-1] #=> true (1.9) false(1.8)
2、systemstackerror现在继承exception类,而非原来的standarderror:
1.8
systemstackerror < standarderror # => true
1.9
systemstackerror < standarderror # => nil
systemstackerror < exception #=> true
3、移除了exception#to_str方法:
begin
raise "foo"
rescue
$!.to_str
#=> undefind method "to_str" for #<runtimeerror:foo>
文章转自庄周梦蝶 ,原文发布时间 2008-10-03