Fantastic observation. My IMHO, I would not call this “clever code”. This “works” because the code of throwing is inside the “handle_call” of the gen_server, so you are “aware” of the fact that these are valid responses for “handle_call”. But if you make good code separation, your handle_call will actually delegate to some other module:function. If that one is throwing an exception that is probably not “gen_server aware”, you now are returning in the handle_call an invalid response which will take you down a rabbit hole to understand why things are behaving “weird”.
Add to that the fact that for really correct testing purposes, you should actually test that any code *after* the throw didn’t execute, and thats just annoying overhead.
So, yeah : don’t try this. At home OR work.