I'm trying to understand the syntax of Ruby-exceptions.
I found this example:
begin
puts "Running with b=#{ b }"
exception_if(b)
puts "After possible exception"
rescue ArgumentError => e
puts "An error occured: #{ e }!"
ensure
puts "Always excuted, no matter what."
end
Source: Wiki-Books
"ArgumentError" is the expection-type, which the rescue-branch shall catch? "e" is the reference-variable?
I'm I right there?
Then I found this snippet and that confused me then completely:
begin
@product = Product.find(params[:id])
rescue => e
redirect_to root_path
end
Where's the first part before the arrow (=>)?
Can someone explain me, how the two snippets are meant?