Project

General

Profile

Actions

Feature #6372

closed

More specific error for uncaught throw

Added by trans (Thomas Sawyer) almost 12 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:44698]

Description

I have this method:

=begin
class Symbol
# Does the block throw the symbol?
#
def thrown?
catch(self) do
begin
yield
true
rescue ArgumentError => err # 1.9 exception
false
rescue NameError => err # 1.8 exception
false
end
end
end
end
=end

But it was recently pointed out to me that the rescue of ArgumentError and NameError is not good enough b/c they might rescue an unrelated error of the same type. So to make this right there needs to be a more specific error. Perhaps class ThrowError < ArgumentError.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0