anli
Ignoring in handle_info/2 is OK. Really?
Hi! The guides suggest a clause
def handle_info(_msg, state) do
{:noreply, state}
end
to handle unexpected messages received by GenServer. But such ignoring can result in ignoring developers’ errors. So, I guess, there can be reasons to crash early on unexpected messages. Or - at least - log them. But not ignoring.
Please, show me where I’m wrong ![]()
Most Liked
josevalim
Btw, Elixir v1.4 will be moving towards to logging in such cases.
josevalim
Sorry. The default implementation for handle_info, which is the catch all
clause for unhandled messages will now log. If you provide your own
clauses, you need your own catch all and your own log though.
gregvaughn
I agree with your point. I would expect to at least log unexpected messages. I suspect the guides’ point is to get people started with minimal tangents. OTP has certain “housekeeping” sorts of messages that come into handle_info that doesn’t make a lot of sense to explain to someone brand new to the framework, and that in many cases you really should just ignore, but I agree with the idea to log them. That way you’ll be aware of them and can start seeing what they mean when you run across them.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










