From a2d6202458fa4dd6d020c5a13eefcd82d714e9a6 Mon Sep 17 00:00:00 2001 From: "feliks.pobiedzinski@swmansion.com" Date: Mon, 27 May 2024 12:10:03 +0200 Subject: [PATCH] Add debug log about error in handling actions --- lib/membrane/core/callback_handler.ex | 18 ++++++++++++++++++ .../integration/links_validation_test.exs | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/membrane/core/callback_handler.ex b/lib/membrane/core/callback_handler.ex index c42a7400c..237d993b4 100644 --- a/lib/membrane/core/callback_handler.ex +++ b/lib/membrane/core/callback_handler.ex @@ -185,6 +185,8 @@ defmodule Membrane.Core.CallbackHandler do Error handling actions returned by callback #{inspect(state.module)}.#{callback} """) + log_debug_orginal_error(actions, e, __STACKTRACE__) + reraise e, __STACKTRACE__ end @@ -198,10 +200,26 @@ defmodule Membrane.Core.CallbackHandler do Error handling action #{inspect(action)} returned by callback #{inspect(state.module)}.#{callback} """) + log_debug_orginal_error(action, e, __STACKTRACE__) + reraise e, __STACKTRACE__ end end) handler_module.handle_end_of_actions(state) end + + defp log_debug_orginal_error(action_or_actions, error, stacktrace) do + action_or_actions = + if(is_list(action_or_actions), do: "actions ", else: "action ") <> + inspect(action_or_actions, limit: :infinity) + + Membrane.Logger.debug(""" + Error while handling #{action_or_actions} + + Orginal error: + #{inspect(error, pretty: true, limit: :infinity)} + #{Exception.format_stacktrace(stacktrace)} + """) + end end diff --git a/test/membrane/integration/links_validation_test.exs b/test/membrane/integration/links_validation_test.exs index 9f69e2f38..973f4921c 100644 --- a/test/membrane/integration/links_validation_test.exs +++ b/test/membrane/integration/links_validation_test.exs @@ -74,7 +74,7 @@ defmodule Membrane.LinksValidationTest do ] {:error, {{%Membrane.LinkError{}, _stackstrace}, _meta}} = - Pipeline.start_supervised(spec: spec) + Pipeline.start_supervised(spec: [spec, spec]) end test "dynamic pads" do