Switching from Python
Overuse of try/catch
Python follows the principle better to ask for forgiveness than permission, which in practice means using try/except
blocks with type checking on the error. In Julia the preference is to avoid the error using an initial check.
Anti-pattern
Overuse of constructs such as:
try
myfunction()
catch e
if isa(e, DomainError)
response()
else
rethrow()
end
end
Though the above is far preferable to the below, which risks triggering a desired response for the wrong error.
try
myfunction()
catch
response()
end
Best practice
if condition()
myfunction()
else
response()
end