How to write a handle_call for gen_server callback with checking user?

钱晓明 <>
Fri Apr 2 00:29:22 CEST 2010


Just a simple question! My handle_call just like this:

handle_call({start, User, Passwd, Algorithm, ScheduledTime, XmlParams}, _From,
State) ->
    Reply = case check_user(User, Passwd) of
                    false ->
                        {error, rejected};
                    _ ->
                        ?INFOLOG("Received request from user ~p for ~p.~n",
[User,Algorithm])
                        % other code for processing user request...
                        % other code for processing user request...
                    end,
    {reply, Reply, State}.

Can I return {reply, {error, rejected}, State} immediately when I find that
check_user return false? How can I write such code?
I was a C++ programmer before, so expecting something like "return"
keyword...
Thanks! All of you give me great favor!


More information about the erlang-questions mailing list