Browse Source

fix: treat all returns except {error, Reason} as ok

Shawn 3 years atrás
parent
commit
5f74db6d88
1 changed files with 5 additions and 4 deletions
  1. 5 4
      apps/emqx_bridge/src/emqx_bridge.erl

+ 5 - 4
apps/emqx_bridge/src/emqx_bridge.erl

@@ -97,11 +97,12 @@ on_message_publish(Message = #message{topic = Topic, flags = Flags}) ->
 send_to_matched_egress_bridges(Topic, Msg) ->
 send_to_matched_egress_bridges(Topic, Msg) ->
     lists:foreach(fun (Id) ->
     lists:foreach(fun (Id) ->
         try send_message(Id, Msg) of
         try send_message(Id, Msg) of
-            ok -> ok;
-            Error -> ?SLOG(error, #{msg => "send_message_to_bridge_failed",
-                        bridge => Id, error => Error})
+            {error, Reason} ->
+                ?SLOG(error, #{msg => "send_message_to_bridge_failed",
+                        bridge => Id, error => Reason});
+            _ -> ok
         catch Err:Reason:ST ->
         catch Err:Reason:ST ->
-            ?SLOG(error, #{msg => "send_message_to_bridge_crash",
+            ?SLOG(error, #{msg => "send_message_to_bridge_exception",
                 bridge => Id, error => Err, reason => Reason,
                 bridge => Id, error => Err, reason => Reason,
                 stacktrace => ST})
                 stacktrace => ST})
         end
         end