I recently wrote some bad code in a GenServer handle_cast callback. I forgot to add the {:noreply, new_state} clause at the end of that callback, so some random other value got returned.
Unfortunately (or fortunately?), the gap between writing the code and testing it (and thus finding this issue) included a break while I went out and enjoyed some adult beverages with some friends and then I came home and slept.
So when I got back to testing it this morning, the new code was not exactly top-of-mind 😅 and I had some challenges parsing this message:
09:43:47.772 [error] GenServer #PID<0.722.0> terminating
** (stop) bad return value: {:ok, #Reference<0.0.1.6782>}
Took me a while to figure out
which GenServer was failing, where "bad return value" was coming from (thank you,Â
GitHub code search), and which code of mine was triggering this error.
Perhaps the error could be extended to include at least the name of the offending module and callback name, something like:
09:43:47.772 [error] GenServer #PID<0.722.0> terminating
** (stop) bad return value {:ok, #Reference<0.0.1.6782>} in MyBorkedServer callback: handle_cast
Thanks!
-Eric