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 end 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 end
#
=> undefind method "to_str" for #<RuntimeError:foo>
文章转自庄周梦蝶 ,原文发布时间 2008-10-03
相关资源:敏捷开发V1.0.pptx