Class: Fabulator::Expr::ErrExpr

Inherits:
Object
  • Object
show all
Defined in:
lib/fabulator/expr/statement_list.rb

Instance Method Summary collapse

Constructor Details

#initialize(e, c) ⇒ ErrExpr

Returns a new instance of ErrExpr.



96
97
98
99
# File 'lib/fabulator/expr/statement_list.rb', line 96

def initialize(e,c)
  @expr = e
  @err_expr = c
end

Instance Method Details

#run(context, autovivify = false) ⇒ Object



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fabulator/expr/statement_list.rb', line 101

def run(context, autovivify = false)
  result = []
  begin
    result = @expr.run(context, autovivify)
  rescue => e
    ctx = context.merge
    ctx.set_var('e', e)
    result = @err_expr.run(ctx)
  end
  result
end