Xgit v0.1.0 Xgit.Util.GenServerUtils
Some utilities to make error handling in GenServer
calls easier.
Xgit is somewhat more exception-friendly than typical Elixir code.
Link to this section Summary
Functions
Makes a synchronous call to the server and waits for its reply.
Delegate a handle_call/3
call to a handle_(something)
call on a module.
Wrap a handle_call/3
call to a handle_(something)
call on a module.
Link to this section Functions
call!(server, request, timeout \\ 5000)
call!(
server :: GenServer.server(),
request :: term(),
timeout :: non_neg_integer()
) :: term()
call!( server :: GenServer.server(), request :: term(), timeout :: non_neg_integer() ) :: term()
Makes a synchronous call to the server and waits for its reply.
Return Value
If the response is :ok
, return server
(for function chaining).
If the response is {:ok, (value)}
, return value
.
If the response is {:error, (reason)}
, raise reason
as an error.
delegate_call_to(mod, function, args, mod_state)
Delegate a handle_call/3
call to a handle_(something)
call on a module.
Wraps common :ok
and error responses and exceptions and returns them to caller.
Unlike wrap_call/4
, assumes that the GenServer
state is a tuple of
{module, mod_state}
and re-wraps module state accordingly.
wrap_call(mod, function, args, prev_state)
Wrap a handle_call/3
call to a handle_(something)
call on a module.
Wraps common :ok
and error responses and exceptions and returns them to caller.
Should be used for standalone modules (i.e. modules that are not open to extension).