You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PythonCall.jl how do I handle Python exceptions? #388
julia> try
@pyexec "raise ValueError('foo')"
catch err
if err isa PyException && pyisinstance(err, pybuiltins.ValueError)
@info "handling a ValueError"
else
rethrow()
end
end
[ Info: handling a ValueError
is roughly equivalent to this in Python
>>> try:
... raise ValueError('foo')
... except ValueError as err:
... print('handling a ValueError')
...
handling a ValueError
Activity
cjdoris commentedon Oct 21, 2023
This in Julia
is roughly equivalent to this in Python
hubert-associates commentedon Oct 21, 2023
Sincere thanks for the quick response. Tricky/frustrating to arrive here without this user's guide pattern ....