Hi,
i am trying to return an error from a function that is defined like so
fn login(client: &Client) -> Result<(), Box<dyn std::error::Error>> {
if _condition_failed_ {
let err = Box::new(Error::new(ErrorKind::Other, "Login failed!"));
return Err(err)
}
}
i came to this solution after trying various combination for an hour.
i read from google, that i should structs that define my own error, or use some crates, but i am working on private project, that i am trying to use only necessary crates, so i can also learn as much as possible on rust std.
is there an easy way to just return an error, and keep using ?
because now i need to define a box in the heap that holds the error, which i also need to initialize.
i am looking for something as simple as Err("Login failed!")
and move on..
Thanks