From 85c090151731ef5b68b192fb8ba44b54a8742e33 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Mon, 11 Nov 2024 20:35:24 -0800 Subject: [PATCH 1/3] fix: update kafee consumer handle_failure/2 fn --- lib/kafee/consumer.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/kafee/consumer.ex b/lib/kafee/consumer.ex index a266e00..950c902 100644 --- a/lib/kafee/consumer.ex +++ b/lib/kafee/consumer.ex @@ -192,6 +192,8 @@ defmodule Kafee.Consumer do @doc false defmacro __using__(opts \\ []) do quote location: :keep, bind_quoted: [opts: opts, module: __CALLER__.module] do + require Logger + @behaviour Kafee.Consumer @doc false @@ -230,8 +232,7 @@ defmodule Kafee.Consumer do inspected_message = inspect(message) inspected_error = inspect(error) - raise RuntimeError, - message: """ + Logger.error(""" An error has been raised while processing a Kafka message. Message: @@ -239,7 +240,7 @@ defmodule Kafee.Consumer do Error: #{inspected_error} - """ + """, kafee_message: message, error: error) end defoverridable child_spec: 1, handle_message: 1, handle_failure: 2 From 5bd546da002a87ba04114e37a648594cfe9c70d7 Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Mon, 11 Nov 2024 20:39:08 -0800 Subject: [PATCH 2/3] update formatting --- lib/kafee/consumer.ex | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/kafee/consumer.ex b/lib/kafee/consumer.ex index 950c902..3adff2d 100644 --- a/lib/kafee/consumer.ex +++ b/lib/kafee/consumer.ex @@ -232,7 +232,8 @@ defmodule Kafee.Consumer do inspected_message = inspect(message) inspected_error = inspect(error) - Logger.error(""" + Logger.error( + """ An error has been raised while processing a Kafka message. Message: @@ -240,7 +241,10 @@ defmodule Kafee.Consumer do Error: #{inspected_error} - """, kafee_message: message, error: error) + """, + kafee_message: message, + error: error + ) end defoverridable child_spec: 1, handle_message: 1, handle_failure: 2 From e6ab1ebf44c2d1f5603110cbbed84b96df6103ac Mon Sep 17 00:00:00 2001 From: Blake Kostner Date: Sat, 16 Nov 2024 15:34:51 -0800 Subject: [PATCH 3/3] trim up logger user data --- lib/kafee/consumer.ex | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/kafee/consumer.ex b/lib/kafee/consumer.ex index 3adff2d..b653081 100644 --- a/lib/kafee/consumer.ex +++ b/lib/kafee/consumer.ex @@ -229,20 +229,13 @@ defmodule Kafee.Consumer do @impl Kafee.Consumer def handle_failure(error, %Kafee.Consumer.Message{} = message) do - inspected_message = inspect(message) - inspected_error = inspect(error) - Logger.error( """ An error has been raised while processing a Kafka message. - Message: - #{inspected_message} - Error: - #{inspected_error} + #{inspect(error)} """, - kafee_message: message, error: error ) end