ArgumentError when trying to debug module and function name

It is not. Let me list things that can be nil (even if very unlikely to ever happen) in your code, and what would happen then:

  1. __MODULE__, but then it would just be interpolated into the empty string, no errormessage or crash at all.
  2. __ENV__, but then you would get an (UndefinedFunctionError) because of nil.function/0 beeing undefined
  3. __ENV__.function, but then Atom.to_string/1 would return "nil"

So if, and only if, really something is nil in the snippet you have shown to us, it would not result in the error message you have shown to us.

In fact, the only way to reproduce your error in an isolated manor, is as I have shown in my direct reply. We have also shown multiple alternatives to get some output that might be similar to what you want.

If you still insist on something beeing nil, than isolate that thing in a minimal example, that shows the nil-value and not an arbitrary error.

Until you have done so, I’ll mark this issue as solved on my perosnal list and I wish you luck with your “problem”.