Skip to content

Commit

Permalink
Stop with bad_return_value on bad return in Agent
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcakez committed Aug 11, 2015
1 parent 5284d17 commit 790173e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/elixir/lib/agent/server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ defmodule Agent.Server do
end

def handle_call({:get_and_update, fun}, _from, state) do
{reply, state} = run(fun, [state])
{:reply, reply, state}
case run(fun, [state]) do
{reply, state} -> {:reply, reply, state}
other -> {:stop, {:bad_return_value, other}, state}
end
end

def handle_call({:update, fun}, _from, state) do
Expand Down

0 comments on commit 790173e

Please sign in to comment.