Having hard time tracking down simple errors

Hi, I have been using elixir in personal projects for some time now and I really appreciate this technology. However, it is difficult for me to find simple errors sometime. It often takes a long time to track a simple error.
The problem arises when errors occur in the processes.
For example I had a following function. It was throwing error because variable state was not map but a keyword list.

      def handle_info({:update_status, status}, state) do
        {:ok, Map.put(state, :status, status)}

I never saw any errors in the terminal when running the app with the iex -S mix.
I saw something was wrong in the observer. Started commenting out line by line and using IO.inspect and puts till I got to the right place.
It took some time and I’ve had such problem multiple times.

Why doesn’t elixir notify me of such errors in the terminal? Can I change some logging level some where or it could be a problem with the app design?

1 Like

The OTP-abstraction error logging tool is called SASL! There are instructions in the logger docs on how to enable it. @bgmarx has an illuminating post on setting it up over here.


Solved my issue here and probably saved many hours :slight_smile: Thanks!

1 Like