Reporting errors with source code position?

Is there any standard rules for reporting errors when metaprogramming?

For the cases that users give wrong data in runtime or they do not properly use a macro, I want to report them the concrete error message with accurate source code position.

3 Likes

Macros will be expanded in the relevant location, so this should happen automatically: for throw you get a stacktrace, for @error the location should be in the logs (with the defaults).

The macro wrapped expression can be large. The error can only automatically located to the macro callsites, but more accurate report should be handled manually.

Besides, some errors can also be detected before finishing the macro transformation, and in the case I think it impossible for errors to get automatically and properly reported.