When designing a macro, what is the best error type to throw for what could be seen as a “syntax error”?
Note that the original poster on Slack cannot see your response here on Discourse. Consider transcribing the appropriate answer back to Slack, or pinging the poster here on Discourse so they can follow this thread.
(Original message ) (More Info)
in DataFramesMeta we throw
ArgumentErrors, I guess because the macros in DataFramesMeta are “functon-like”.
Dhairya 17 hours ago
Depends on the context. If you’re producing invalid regular Julia then the compiler would error for you, if it’s a DSL, then you might want to throw a custom exception if you can catch the exact issue - that would be more informative, or else an
ErrorException would do
Heetbeet 17 hours ago
Thanks, yes it’s a DSL. I think I’ll then go with ErrorException
ErrorException is basically the same type of error you would get with an actual syntax error. So that is probably the closest to the real deal, but
ArgumentError is probably the most helpful when you are in the pre-processing the macro arguments phase.