May 2019
Beginner to intermediate
466 pages
10h 44m
English
As developers, we too have the option to create and throw exceptions when our code encounters a problem and shouldn't continue. Julia provides a long list of built-in exceptions that cover a multitude of use cases. You can read about them at https://docs.julialang.org/en/stable/manual/control-flow/#Built-in-Exceptions-1.
In order to throw an exception, we use the aptly named throw function. For example, if we want to replicate the error raised by Gumbo's getattr method, all we have to do is call the following:
julia> throw(KeyError("href"))
ERROR: KeyError: key "href" not found
If the built-in exceptions provided by Julia aren't relevant enough for your situation, the language provides a generic error type, ...
Read now
Unlock full access