Given the two files
test.jl
:
f(; kwargs...) = dump(kwargs)
try
f(a=1, b=2, a=7)
catch ex
println("Caught exception!")
dump(ex)
end
and testincl.jl
:
try
include("test.jl")
catch ex
println("Caught exception!")
dump(ex)
end
I get
$ julia test.jl
ERROR: LoadError: syntax: keyword argument "a" repeated in call to "f" around test.jl:4
Stacktrace:
[1] top-level scope
@ test.jl:3
in expression starting at test.jl:3
$ julia testincl.jl
Caught exception!
LoadError
file: String "test.jl"
line: Int64 3
error: ErrorException
msg: String "syntax: keyword argument \"a\" repeated in call to \"f\" around test.jl:4"
I guess it’s somewhat difficult to define how catching syntax errors should work (since after all, the program is not well-formed in that case). It looks like it’s not possible within the same file (or REPL), but maybe there’s some “hidden” way?