-module(serv).
-behaviour(gen_server).

-export([start_link/0]).
-export([question/0, fail/0]).
-export([init/1, handle_call/3, handle_cast/2]).
-export([terminate/2, handle_info/2, code_change/3]).

start_link() ->
    gen_server:start_link({local, serv}, serv, [], []).

question() ->
    gen_server:call(serv, question).

fail() ->
    gen_server:call(serv, fail).

init(_Args) ->
    {ok, []}.

handle_call(question, _From, State) ->
    {reply, 42, State};

handle_call(fail, _From, State) ->
    X = 1,
    % The following command will cause "bad match"
    X = 2,
    {reply, 42, State}.

handle_cast(_, State) ->
    {noreply, State}.

handle_info(_, State) ->
    {noreply, State}.

terminate(_, _) ->
    ok.

code_change(_, State, _) ->
    {ok, State}.
