Current behavior of %julia magic is to print exception from Julia to stderr and continue executing. This is not ideal because
A language interface library should not hide exception. If there is an exception, let users handle it. This is particularly important for line magics which can be surrounded by normal Python code.
It was inconsistent in that Python errors thrown in Julia are actually properly raised. (This was something I noticed while reviewing #262 and found test failures like this)
Reading PR #14 (where this behavior was introduced), it seems that the aim was for making the error clear. This is better be done using _render_traceback_. It's actually pretty easy to use it. Just adding
class JuliaError(Exception):
def _render_traceback_(self):
return [str(self)]
yields
In [22]: Main.eval("""error("some error")""")
Exception 'some error' occurred while calling julia code:
error("some error")
Note that the error message is succinct even without %julia magic (as long as you are in IPython). However, this is probably too succinct to recognize it as an exception. We need to include Julia traceback to make it more informative and look like an exception. As it takes a bit more coding, let's just stop catching exception in %julia magic (already done in #265) and then worry about traceback later. This way, we don't have to change the programmable interface later.
Current behavior of
%julia
magic is to print exception from Julia to stderr and continue executing. This is not ideal becauseA language interface library should not hide exception. If there is an exception, let users handle it. This is particularly important for line magics which can be surrounded by normal Python code.
It was inconsistent in that Python errors thrown in Julia are actually properly
raise
d. (This was something I noticed while reviewing #262 and found test failures like this)Reading PR #14 (where this behavior was introduced), it seems that the aim was for making the error clear. This is better be done using
_render_traceback_
. It's actually pretty easy to use it. Just addingyields
Note that the error message is succinct even without
%julia
magic (as long as you are in IPython). However, this is probably too succinct to recognize it as an exception. We need to include Julia traceback to make it more informative and look like an exception. As it takes a bit more coding, let's just stop catching exception in%julia
magic (already done in #265) and then worry about traceback later. This way, we don't have to change the programmable interface later.