anchor.diff:  
   payload_type(_Type) -> none.
   
  -
   handle({Type, Body}, S) ->
  -   %error_logger:info_report({"Got request", Type, Body}),
      case catch mochijson2:decode(Body) of
           {'EXIT', _} ->
  -            {error, {fatal,
  -                     ["Corrupted message: type '", Type, "', body:\n", Body]}};
  +            Err = ["Payload is not valid JSON: type '", Type, "', body:\n", Body],
  +            {error, {fatal, Err}};
           Json ->
  -           %error_logger:info_report({"worker: handling", Type, Json}),
  -           case payload_type(Type) of
  -               none -> ok;
  -               Spec -> case json_validator:validate(Spec, Json) of
  -                           ok -> ok;
  -                           E -> error_logger:error_report({"invalid payload type", Type, E})
  -                       end
  -           end,
  -           Ret = do_handle({Type, Json}, S),
  -           %error_logger:info_report({"Return", Ret}),
  -           Ret
  +            case payload_type(Type) of
  +                none ->
  +                    Err = ["Unknown message type '", Type, "', body:\n", Body],
  +                    {error, {fatal, Err}};
  +                Spec ->
  +                    case json_validator:validate(Spec, Json) of
  +                        ok ->
  +                            do_handle({Type, Json}, S);
  +                        {error, E} ->
  +                            Msg = "Invalid message body (type '~s'): ~p",
  +                            {error, {fatal, io_lib:format(Msg, [Type, E])}}
  +                    end
  +            end
       end.
   
   do_handle({<<"PID">>, Pid}, S) ->
  
positive.code: 
  do_handle({<<"INP">>, [<<"exclude">>, Iids]}, #state{inputs = Inputs} = S) ->
      {ok, input_reply(worker_inputs:exclude(Iids, Inputs)), S};
  
  do_handle({<<"INP">>, _}, _S) ->
      {stop, {fatal, "Invalid INP request"}};
  
  do_handle({<<"EREP">>, [Iid, Rids]}, #state{inputs = Inputs} = S) ->
      Inputs1 = worker_inputs:fail(Iid, Rids, Inputs),
  
negative.code:             {stop, {done, results(S)}};
          {error, Reason} ->
              {stop, {error, Reason}}
      end.
  
  input_reply(Inputs) ->
      {"INP", [<<"done">>, [[Iid, <<"ok">>, Repl] || {Iid, Repl} <- Inputs]]}.
  