julia> macro foo(ex) :($ex ? nothing : error("Assertion failed: ", $(string(ex)))) end julia> @foo 2 > 0 julia> @foo 2 > 3 ERROR: Assertion failed: :((2>3)) in error at error.jl:22
julia> macro foo(ex, msg) :($ex ? nothing : error("$($msg): ", $(string(ex)))) end julia> @foo(2 > 3, "aaa") ERROR: aaa: :((2>3)) in error at error.jl:22 julia> @foo 2 > 3, "aaa" ERROR: wrong number of arguments