7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/jactive_support/rescuable.rb', line 7
def rescue_from(*klasses, &block)
options = klasses.
unless options.has_key?(:with)
if block_given?
options[:with] = block
else
raise ArgumentError, "Need a handler. Supply an options hash that has a :with key as the last argument."
end
end
klasses.each do |klass|
key = if klass.is_a?(Class) && ( klass <= Exception || klass <= ::Java::JavaLang::Exception )
klass.name
elsif klass.is_a?(String)
klass
else
raise ArgumentError, "#{klass} is neither an Exception nor a String"
end
self.rescue_handlers += [[key, options[:with]]]
end
end
|