Method: Red::ControlNode::RescueNode#initialize
- Defined in:
- lib/red/control_nodes.rb
#initialize(attempted, rescue_body) ⇒ RescueNode
Returns a new instance of RescueNode.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/red/control_nodes.rb', line 52 def initialize(attempted, rescue_body) raise(BuildError::NoArbitraryRescue, "JavaScript does not support arbitrary placement of rescue/try blocks") unless @@rescue_is_safe raise(BuildError::NoSpecificRescue, "JavaScript does not support rescuing of specific exception classes") unless !rescue_body[1] @@rescue_is_safe == false @attempted = attempted.build_node if (block = (rescue_body.assoc(:block) || [])[1..-1]) && block.first.last == [:gvar, %s($!)] exception_node = block.shift @exception_variable = exception_node[1].build_node @rescued = block.unshift(:block).build_node else @exception_variable = :e.build_node @rescued = rescue_body[2].build_node end end |