May 2019
Beginner to intermediate
466 pages
10h 44m
English
But what do we do if we realize that the exception we've caught cannot (or should not) be handled by our code? For example, say we were expecting to catch a possible missing attribute, but it turned out we got a Gumbo parsing exception instead. Such an issue would have to be handled higher up the execution stack, maybe by trying to fetch the web page again and reparsing it, or by logging an error message for the admin.
If we throw the exception ourselves, the origin (the stacktrace) of the initial error would be lost. For such cases, Julia provides the rethrow function, which can be used as follows:
julia> try
Dict()[:foo]
catch ex
"nothing to see here"
end
"nothing to see here"
If we simply throw the exception ourselves, ...
Read now
Unlock full access