diff --git a/lib/membrane/core/callback_handler.ex b/lib/membrane/core/callback_handler.ex index 7b0746cbe..30cb8d3bc 100644 --- a/lib/membrane/core/callback_handler.ex +++ b/lib/membrane/core/callback_handler.ex @@ -141,7 +141,12 @@ defmodule Membrane.Core.CallbackHandler do e in UndefinedFunctionError -> with %{module: ^module, function: ^callback, arity: arity} <- e do reraise CallbackError, - [kind: :not_implemented, callback: {module, callback}, arity: arity], + [ + kind: :not_implemented, + callback: {module, callback}, + arity: arity, + args: args + ], __STACKTRACE__ end diff --git a/lib/membrane/exceptions.ex b/lib/membrane/exceptions.ex index df28edb6f..1fb05f224 100644 --- a/lib/membrane/exceptions.ex +++ b/lib/membrane/exceptions.ex @@ -59,6 +59,28 @@ defmodule Membrane.CallbackError do %__MODULE__{message: msg} end + defp mk_exception(:not_implemented, {module, :handle_child_pad_removed}, opts) do + [child, pad, _context, _custom_state] = Keyword.fetch!(opts, :args) + + component_type_string = + cond do + Membrane.Pipeline.pipeline?(module) -> "Pipeline" + Membrane.Bin.bin?(module) -> "Bin" + end + + callback_ref = "`c:Membrane.#{component_type_string}.handle_child_pad_removed/4`" + + msg = """ + Bin #{inspect(child)} removed its pad #{inspect(pad)}, but callback #{callback_ref} is not implemented in #{inspect(module)}. + + This means, that `#{inspect(child)} removed the pad on its own, without knowledge of its parent. For example it could happen due to removing #{inspect(child)}'s child linked to the #{inspect(child)}'s inner pad or by removing link between #{inspect(child)} and its child. + + If you want to handle this scenario, implement #{callback_ref} callback in #{inspect(module)}. + """ + + %__MODULE__{message: msg} + end + defp mk_exception(:not_implemented, {module, fun}, opts) do arity = Keyword.fetch!(opts, :arity)