Top Level Namespace

Defined Under Namespace

Modules: Capricorn, ErlangHelpers Classes: InternalError, Object

Instance Method Summary collapse

Instance Method Details

#Erlang(&block) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/capricorn/driver.rb', line 64

def Erlang(&block)
  ErlangHelpers.setup

  loop do
    cmd = ErlangHelpers.receive

    if cmd == :stop
      exit(0)
    end

    begin
      ctx = Object.new
      ctx.extend ErlangHelpers
      ctx.instance_exec(cmd, &block)
    rescue InternalError => e
      ErlangHelpers.send BERT::Tuple[:error, BERT::Tuple[*e.args]]
    rescue RuntimeError => e
      ErlangHelpers.send BERT::Tuple[:error, BERT::Tuple[:runtime, e.class.to_s, e.message, e.backtrace]]
    rescue Exception => e
      ErlangHelpers.send BERT::Tuple[:error, BERT::Tuple[:system, e.class.to_s, e.message, e.backtrace]]
    end
  end
end