x-EricH-x
Calling super for GenServer callback handle_info/2 is deprecated, what is the proper solution?
this is related to an earlier post I made.
In that post I ask for a generic solution to call the an overridden function and super is suggested as the answer.
However, to my surprise, it actually does not work for the particular case of handle_info of GenServer, and a warning msg Calling super for GenServer callback handle_info/2 is deprecated is shown.
I did some googling but could find a proper solution, any suggestions/ideas?
example code:
defmodule Foo do
use GenServer
# this generate warning msg
# 'Calling super for GenServer callback handle_info/2 is deprecated'
def handle_info(msg, state), do: super(msg, state)
end
Marked As Solved
lud
This is the default injected handle_info/2 implementation: elixir/gen_server.ex at main · elixir-lang/elixir · GitHub
Basically it just does log an error message sayingSomeModule #PID<0.111.0> received unexpected message in handle_info/2: :some_message.
I assume it is deprecated because unexpected messages should be handled by explicit logging, or by not defining a function clause accepting them and crash.
In your code example, as your function only calls super/2, you can just remove it altogether and you are good. If you want to add your own handle_info clauses and still want to log unexpected messages, you should do it explicitely.







