Skip to content

Commit

Permalink
wrap sprint in try-catch block and print in debug
Browse files Browse the repository at this point in the history
  • Loading branch information
glennmoy committed Jul 5, 2023
1 parent 83a21bb commit a0f461d
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/cpython/jlwrap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,13 @@ function _pyjl_serialize(self::PyPtr, ::PyPtr)
b = take!(io)
return PyBytes_FromStringAndSize(pointer(b), sizeof(b))
catch e
PyErr_SetString(
POINTERS.PyExc_Exception,
"error serializing this value. Caught exception $(sprint(showerror, e, catch_backtrace()))"
)
PyErr_SetString(POINTERS.PyExc_Exception, "error serializing this value")
# wrap sprint in another try-catch block to prevent this function from throwing
try
@debug "Caught exception $(sprint(showerror, e, catch_backtrace()))"
catch e2
@debug "Error printing exception: $e2"
end
return PyNULL
end
end
Expand All @@ -223,10 +226,13 @@ function _pyjl_deserialize(t::PyPtr, v::PyPtr)
x = deserialize(io)
return PyJuliaValue_New(t, x)
catch e
PyErr_SetString(
POINTERS.PyExc_Exception,
"error deserializing this value. Caught exception $(sprint(showerror, e, catch_backtrace()))"
)
PyErr_SetString(POINTERS.PyExc_Exception, "error deserializing this value")
# wrap sprint in another try-catch block to prevent this function from throwing
try
@debug "Caught exception $(sprint(showerror, e, catch_backtrace()))"
catch e2
@debug "Error printing exception: $e2"
end
return PyNULL
end
end
Expand Down

0 comments on commit a0f461d

Please sign in to comment.