fix zd_consumer

This commit is contained in:
anlicheng 2023-12-25 15:41:35 +08:00
parent b0e7b6599e
commit bce32598d3

View File

@ -158,8 +158,21 @@ handle_info({directive_reply, Reply}, State = #state{logger_pid = LoggerPid, fli
FlightInfo = <<"flight_num: ", (integer_to_binary(FlightNum - 1))/binary>>,
case Reply of
{ok, RawReq, DirectiveResult} ->
case DirectiveResult of
ok ->
iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, <<"OK">>, FlightInfo]);
{ok, Response} when is_binary(Response) ->
iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, Response, FlightInfo]);
{error, Reason0} ->
Reason = if
is_atom(Reason0) -> atom_to_binary(Reason0);
is_binary(Reason0) -> Reason0;
true -> <<"Unknow error">>
end,
iot_logger:write(LoggerPid, [<<"[error]">>, RawReq, Reason, FlightInfo])
end,
iot_logger:write(LoggerPid, [<<"[success]">>, RawReq, DirectiveResult, FlightInfo]);
{error, RawReq, Error} ->
{error, RawReq, Error} when is_binary(Error) ->
iot_logger:write(LoggerPid, [<<"[error]">>, RawReq, Error, FlightInfo])
end,
{noreply, State#state{flight_num = FlightNum - 1}};