Sha256: 2ffc1eae0301d264b33b0b9ed1ee5c5eb9ee9f85ed50b85a2e037eb06fbe08da

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 Bytes

Contents

-module(ernie_native).
-export([process/2]).
-include_lib("ernie.hrl").

process(ActionTerm, Request) ->
  {_Type, Mod, Fun, Args} = ActionTerm,
  Sock = Request#request.sock,
  logger:debug("Calling ~p:~p(~p)~n", [Mod, Fun, Args]),
  try apply(Mod, Fun, Args) of
    Result ->
      logger:debug("Result was ~p~n", [Result]),
      Data = bert:encode({reply, Result}),
      gen_tcp:send(Sock, Data)
  catch
    error:Error ->
      BError = list_to_binary(io_lib:format("~p", [Error])),
      Trace = erlang:get_stacktrace(),
      BTrace = lists:map(fun(X) -> list_to_binary(io_lib:format("~p", [X])) end, Trace),
      Data = term_to_binary({error, [user, 0, <<"RuntimeError">>, BError, BTrace]}),
      gen_tcp:send(Sock, Data)
  end,
  ok = gen_tcp:close(Sock),
  ernie_server:fin(),
  Log = Request#request.log,
  Log2 = Log#log{tdone = erlang:now()},
  Request2 = Request#request{log = Log2},
  ernie_access_logger:acc(Request2).

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ernie-2.5.2 elib/ernie_native.erl
ernie-2.5.1 elib/ernie_native.erl
ernie-2.5.0 elib/ernie_native.erl
ernie-2.4.0 elib/ernie_native.erl
ernie-2.3.0 elib/ernie_native.erl