← Back to Ruby Operators

Rescue Assignment

The => symbol, in addition to being the hash rocket, can be used in a rescue statement to assign the exception to a variable. This allows you to access data on the exception.

begin
  do_something
rescue ApiException => e
  Rails.logger.error(e.full_message)
end

References