PyCall.jl icon indicating copy to clipboard operation
PyCall.jl copied to clipboard

Prettyerrors

Open jw3126 opened this issue 4 years ago • 2 comments

On master the following snippet:

using PyCall
py"""
def raise_multi_line_error():
    raise Exception("1\n2\n3\n4\n")
"""
py"raise_multi_line_error"()

gives

ERROR: LoadError: PyError ($(Expr(:escape, :(ccall(#= /home/jan/.julia/dev/PyCall/src/pyfncall.jl:43
 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'Exception'>
Exception('1\n2\n3\n4\n')
  File "/home/jan/.julia/dev/PyCall/src/pyeval.jl", line 2, in raise_multi_line_error
    const Py_file_input = 257

This is hard to read. See also #843 . With this PR it becomes:

ERROR: LoadError: PyError:
1
2
3
4

  File "/home/jan/.julia/dev/PyCall/src/pyeval.jl", line 2, in raise_multi_line_error
    const Py_file_input = 257

jw3126 avatar Oct 02 '20 14:10 jw3126

Is there interest in this PR?

jw3126 avatar Oct 09 '20 14:10 jw3126

@stevengj can you briefly comment if there is interest in this PR? So I know if I should polish / redesign / abandon it.

jw3126 avatar Oct 12 '20 07:10 jw3126