throw(ErrorException(...)) vs. @error

I understand that they are different. My point was that I want the same code (detecting some problem) to do different things depending on the context. Put me in a debugger with a stack trace if I’m running interactively. Log if the same code is running in “batch mode” on a server.

Is there a smooth Julia way to do that?