`@error` message from module user's point of view


When I call @error, it includes in the generated log message the filename and line number of where I called @error. However, when I am the author of a module, and I called @error in order to report that the caller of the module caused an error, then it would be nicer to log the filename and line number where the user of the module called the module, as this is most likely where the user needs to fix the mistake in their code.

Is there a convenient way to raise an @error such that the line number displayed is from the module user’s point of view? I can see that @error can accept a backtrace value along with an exception and I also found a Base.StackTraces.remove_frames! that removes from a stacktrace all frames related to a module, but I haven’t quite understood yet how these are meant to fit together (as backtraces and stackframes are different types).

Essentially I’m looking for Julia’s equivalent of Perl’s carp() function.