May 2019
Beginner to intermediate
466 pages
10h 44m
English
If you identify parts of your code where you think the execution can go off the rails due to conditions that are out of your control (that is, exceptional conditions—hence the name exception), you can use Julia's try...catch statements. This is exactly what it sounds like—you instruct the compiler to try a piece of code and if, as a result of a problem, an exception is thrown, to catch it. The fact that an exception is caught implies that it won't propagate throughout the whole application.
Let's see it in action:
julia> try
getattr(dom.root, "href")
catch
println("The $(tag(dom.root)) tag doesn't have a 'href' attribute.")
end
The HTML tag doesn't have a 'href' attribute.
In this example, once an error is encountered, ...
Read now
Unlock full access