pub struct Error { /* private fields */ }
Expand description
This class represents an error that occured in Fisher.
It contains all the details known about it, and you can either access it programmatically or display the error message to the user, already formatted. It also support automatic conversion from the error types of the libraries Fisher depends on.
Implementations§
Source§impl Error
impl Error
Sourcepub fn new(kind: ErrorKind) -> Self
pub fn new(kind: ErrorKind) -> Self
Create a new error. You need to provide the kind of error that occured.
§Example
fn my_function() -> Result<()> {
let error = Error::new(ErrorKind::Dummy);
Err(error)
}
Sourcepub fn set_location(&mut self, location: ErrorLocation)
pub fn set_location(&mut self, location: ErrorLocation)
Set the location where the error occured.
Sourcepub fn location(&self) -> &ErrorLocation
pub fn location(&self) -> &ErrorLocation
Get the location where the error occured. You can either access it programmatically or print a pretty version of it to the user.
Sourcepub fn kind(&self) -> &ErrorKind
pub fn kind(&self) -> &ErrorKind
Get the kind of error occured. You can either access it programmatically or print a pretty version of it to the user.
Sourcepub fn pretty_print(&self)
pub fn pretty_print(&self)
Show a nicely-formatted version of the error, usually for printing it to the user. The function uses ANSI formatting codes.
if let Err(error) = do_work() {
error.pretty_print();
}