Attribute Macro subplotlib::prelude::throws
#[throws]Expand description
Indicate what type a function throws
This attribute macro comes from the fehler crate and is used
to indicate that a function “throws” a particular kind of error.
#[throws(io::Error)]
fn create_thingy() {
// something which might cause an io::Error
}It transforms a function such that the above function would be compiled effectively as:
fn create_thingy() -> Result<(), io::Error> {
// something which might cause an io::Error
Ok(())
}Return statements and the final expression of the function automatically
get wrappered with Ok. You can use the
throw macro inside such a function to automatically return
an error.