GenServer Error: 'function not exported'

2021-08-29T03:28:01.439206+00:00 error: Generic server 'Elixir.Server.FooMonitor' terminating. Reason: {'function not exported',[{'Elixir.Map',get,[filled],[]},{'Elixir.Foo',update_db_tables,1,[{file,"lib/Bosh/Foo.ex"},{line,50}]},{'Elixir.Enum','-map/2-lists^map/1-0-',2,[{file,"lib/enum.ex"},{line,1582}]},{'Elixir.Server.FooMonitor',handle_info,2,[{file,"lib/GenServers/Server.FooMonitor.ex"},{line,20}]},{gen_server,try_dispatch,4,[{file,"gen_server.erl"},{line,695}]},{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,771}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,226}]}]}. Last message: tick. State: [].

What does 'function not exported' not exported mean and how is this issue avoided?

Show the offending code?

From the error stack trace you can read {'Elixir.Map',get,[filled],[]}. This means function in module :"Elixir.Map" (which is the Map module). The function name is :get. The arguments were [:filled]. To translate that to Elixir code, it’s the call Map.get(:filled).

There is no such function in Map, so an error is raised. “Function not exported” means that the Map module doesn’t export such a function. Exporting is an Erlang term, where you can have internal functions in a module that aren’t exported outside (similarly to defp in Elixir). In Elixir all public functions (def) are exported.


Awesome explanation, thanks so much! :slight_smile: